Use browser time formatting instead of Moment

Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2022-02-23 10:42:51 -08:00 committed by GitHub
parent c88f10bac2
commit 5c8cc2dc94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 11 deletions

View File

@ -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(