diff --git a/src/app/pages/chat/group-messages/group-messages.page.html b/src/app/pages/chat/group-messages/group-messages.page.html index 48cab411f..59c31cf5f 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.html +++ b/src/app/pages/chat/group-messages/group-messages.page.html @@ -55,7 +55,7 @@
{{msg.u.name ?? ""}} - {{msg.duration}} + {{msg.time}}
{{msg.msg}} @@ -79,7 +79,7 @@
{{msg.u.name ?? ""}} - {{msg.duration}} + {{msg.time}}
diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html index 49bcd4cd4..4a3e43798 100644 --- a/src/app/pages/chat/messages/messages.page.html +++ b/src/app/pages/chat/messages/messages.page.html @@ -53,7 +53,7 @@ *ngIf="msg.msg !=''" [class.dateLabel]="msg.dateLabel">
{{msg.u.name}} - {{msg.duration}} + {{msg.time}}
@@ -80,7 +80,7 @@
{{msg.u.name}} - {{msg.duration}} + {{msg.time}}
diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 91ee981b5..9dc3d0ccd 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -5,6 +5,7 @@ import { capitalizeTxt } from 'src/plugin/text'; import { NfService } from 'src/app/services/chat/nf.service'; import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'; import { showDateDuration } from 'src/plugin/showDateDuration'; +import { showTimeDuration } from 'src/plugin/showTimeDuration'; import { ChatMethodsService } from './chat-methods.service'; import { MessageModel, attachments } from '../../models/beast-orm'; import { AESEncrypt } from '../aesencrypt.service'; @@ -49,6 +50,7 @@ export class MessageService { loadHistory = false from: 'Offline'|'History'|'stream'| 'send' duration = '' + time= ''; localReference = null viewed: string[] = [] received: string[]= [] @@ -141,6 +143,7 @@ export class MessageService { } this.calDateDuration() + this.calTime() } @@ -449,6 +452,10 @@ export class MessageService { this.duration = showDateDuration(date || this._updatedAt); } + private calTime(time = null) { + this.time = showTimeDuration(time || this._updatedAt); + } + async delateStatusFalse() { this.delate = true @@ -747,6 +754,7 @@ export class MessageServiceDateLabel { loadHistory = false from: 'Offline'|'History'|'stream'| 'send' duration = '' + time = '' localReference = null viewed: string[] = [] received: string[]= [] @@ -816,6 +824,7 @@ export class MessageServiceDateLabel { } this.calDateDuration() + this.calTime(); } @@ -889,6 +898,10 @@ export class MessageServiceDateLabel { this.duration = showDateDuration(date || this._updatedAt); } + private calTime(time = null) { + this.time = showTimeDuration(time || this._updatedAt); + } + async delateStatusFalse() { diff --git a/src/app/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html index bb27fb973..70e6e38a4 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.html +++ b/src/app/shared/chat/group-messages/group-messages.page.html @@ -51,7 +51,7 @@
{{msg.u.name}} - {{msg.duration}} + {{msg.time}}
{{msg.msg}} @@ -82,7 +82,7 @@
{{msg.u.name}} - {{msg.duration}} + {{msg.time}}
diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index ab245d97d..f0b860880 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -50,7 +50,7 @@
{{msg.u.name}} - {{msg.duration}} + {{msg.time}}
@@ -84,7 +84,7 @@
{{msg.u.name}} - {{msg.duration}} + {{msg.time}}
diff --git a/src/plugin/showDateDuration.js b/src/plugin/showDateDuration.js index 9dae76b48..cd87c2967 100644 --- a/src/plugin/showDateDuration.js +++ b/src/plugin/showDateDuration.js @@ -39,6 +39,7 @@ function showDateDuration(start) { } } + module.exports = { - showDateDuration: showDateDuration, + showDateDuration: showDateDuration }; diff --git a/src/plugin/showTimeDuration.js b/src/plugin/showTimeDuration.js new file mode 100644 index 000000000..061502107 --- /dev/null +++ b/src/plugin/showTimeDuration.js @@ -0,0 +1,32 @@ +function addZero(i) { + if (i < 10) { + i = "0" + i; + } + return i; +} + + +function showTimeDuration(start) { + 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; + + let time = start.getHours() + ":" + addZero(start.getUTCMinutes()); + + return time; +} + +module.exports = { + showTimeDuration: showTimeDuration, +};