From 9eccabdd174b598538a2f4e8ba893619fdb83345 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Mon, 6 Sep 2021 17:02:45 +0100 Subject: [PATCH] save --- src/app/pages/chat/chat.page.ts | 37 +++------------------------------ 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts index 2ec8c44fb..7aebfece6 100644 --- a/src/app/pages/chat/chat.page.ts +++ b/src/app/pages/chat/chat.page.ts @@ -27,6 +27,7 @@ import { EventPerson } from 'src/app/models/eventperson.model'; import { removeDuplicate } from 'src/plugin/removeDuplicate.js' import { environment } from 'src/environments/environment'; import { NotificationsService } from 'src/app/services/notifications.service'; +import { TimeService } from 'src/app/services/functions/time.service'; @Component({ selector: 'app-chat', @@ -117,6 +118,7 @@ export class ChatPage implements OnInit { private storage:Storage, private resolver: ComponentFactoryResolver, private route: Router, + private timeService: TimeService, ){ this.loggedUserChat = authService.ValidatedUserChat['data']; this.headers = new HttpHeaders(); @@ -416,40 +418,7 @@ 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.getDate() + "/" + (start.getMonth()+1) + "/" + start.getFullYear(); - return date; - } - } - - addZero(i) { - if (i < 10) { - i = "0" + i; - } - return i; + return this.timeService.showDateDuration(start); } async getChatMembers(){