Use browser time formatting instead of Moment
This commit is contained in:
parent
3ad6ff7f05
commit
1f191401aa
1 changed files with 6 additions and 11 deletions
|
@ -66,20 +66,12 @@ export function formatDateTimeShort(
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const diff = now - timestamp;
|
const diff = now - timestamp;
|
||||||
|
|
||||||
if (diff < MINUTE) {
|
if (diff < HOUR || isToday(timestamp)) {
|
||||||
return i18n('justNow');
|
return formatTime(i18n, rawTimestamp);
|
||||||
}
|
|
||||||
|
|
||||||
if (diff < HOUR) {
|
|
||||||
return i18n('minutesAgo', [Math.floor(diff / MINUTE).toString()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const m = moment(timestamp);
|
const m = moment(timestamp);
|
||||||
|
|
||||||
if (isToday(timestamp)) {
|
|
||||||
return m.format('LT');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diff < WEEK && m.isSame(now, 'month')) {
|
if (diff < WEEK && m.isSame(now, 'month')) {
|
||||||
return m.format('ddd');
|
return m.format('ddd');
|
||||||
}
|
}
|
||||||
|
@ -123,7 +115,10 @@ export function formatTime(
|
||||||
return i18n('minutesAgo', [Math.floor(diff / MINUTE).toString()]);
|
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(
|
export function formatDate(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue