diff --git a/src/app/pages/chat/chat.page.html b/src/app/pages/chat/chat.page.html
index 9d8259898..74f7fa641 100644
--- a/src/app/pages/chat/chat.page.html
+++ b/src/app/pages/chat/chat.page.html
@@ -63,7 +63,7 @@
-
{{dm._updatedAt | date: 'HH:mm'}}
+ {{showDateDuration(dm._updatedAt)}}
{{dm.lastMessage.msg}}
diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts
index ab87827d8..3385911d9 100644
--- a/src/app/pages/chat/chat.page.ts
+++ b/src/app/pages/chat/chat.page.ts
@@ -138,6 +138,10 @@ export class ChatPage implements OnInit {
/* Fim websocket functions */
this.hideRefreshButton();
this.getChatMembers();
+
+ //Teste
+ let t = this.showDateDuration(new Date());
+ console.log(t);
}
hideRefreshButton(){
@@ -368,6 +372,43 @@ hideRefreshButton(){
});
}
+ showDateDuration(start:any){
+ let end;
+ end = new Date();
+ start = new Date(start);
+ let customizedDate;
+
+ const totalSeconds = Math.floor((end - (start))/1000);;
+ const totalMinutes = Math.floor(totalSeconds/60);
+ const totalHours = Math.floor(totalMinutes/60);
+ const totalDays = Math.floor(totalHours/24);
+
+ const hours = totalHours - ( totalDays * 24 );
+ const minutes = totalMinutes - ( totalDays * 24 * 60 ) - ( hours * 60 );
+ const seconds = totalSeconds - ( totalDays * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 );
+
+ if(totalDays == 0){
+ if(start.getDate() == new Date().getDate()){
+ let time = start.getHours() + ":" + this.addZero(start.getUTCMinutes());
+ return time;
+ }
+ else{
+ return 'Ontem';
+ }
+ }
+ else{
+ let date = (start.getDay()+1) + "/" + (start.getMonth()+1) + "/" + start.getFullYear();
+ return date;
+ }
+ }
+
+ addZero(i) {
+ if (i < 10) {
+ i = "0" + i;
+ }
+ return i;
+ }
+
async getChatMembers(){
//return await this.chatService.getMembers(roomId).toPromise();
this.chatService.getAllUsers().subscribe(res=> {