From 5c8cc2dc94ec579576362ebe6dcfd0201b954a7e Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Wed, 23 Feb 2022 10:42:51 -0800 Subject: [PATCH] Use browser time formatting instead of Moment Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> --- ts/util/timestamp.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/ts/util/timestamp.ts b/ts/util/timestamp.ts index 693d4497e..be8ebfe31 100644 --- a/ts/util/timestamp.ts +++ b/ts/util/timestamp.ts @@ -66,20 +66,12 @@ export function formatDateTimeShort( const now = Date.now(); const diff = now - timestamp; - if (diff < MINUTE) { - return i18n('justNow'); - } - - if (diff < HOUR) { - return i18n('minutesAgo', [Math.floor(diff / MINUTE).toString()]); + if (diff < HOUR || isToday(timestamp)) { + return formatTime(i18n, rawTimestamp); } const m = moment(timestamp); - if (isToday(timestamp)) { - return m.format('LT'); - } - if (diff < WEEK && m.isSame(now, 'month')) { return m.format('ddd'); } @@ -123,7 +115,10 @@ export function formatTime( return i18n('minutesAgo', [Math.floor(diff / MINUTE).toString()]); } - return moment(timestamp).format('LT'); + return new Date(timestamp).toLocaleTimeString([], { + hour: 'numeric', + minute: '2-digit', + }); } export function formatDate(