Use Intl.DateTimeFormat instead of momentjs where we can

Need to solve the Intl.RelativeTimeFormat to drop momentjs
This commit is contained in:
djmaze 2020-10-15 00:26:40 +02:00
parent a177081224
commit 6f585e1f1d
5 changed files with 115 additions and 214 deletions

View file

@ -12,13 +12,14 @@ export function format(timeStampInUTC, formatStr) {
case 'SHORT': {
if (4 >= (now - time) / 3600000)
return m.fromNow();
const ymd = m.format('Ymd'), date = new Date;
if (date.format('Ymd') === ymd)
const mt = m.getTime(), date = new Date,
dt = date.setHours(0,0,0,0);
if (mt > dt)
return i18n('MESSAGE_LIST/TODAY_AT', {TIME: m.format('LT')});
if (new Date(now - 86400000).format('Ymd') === ymd)
if (mt > dt - 86400000)
return i18n('MESSAGE_LIST/YESTERDAY_AT', {TIME: m.format('LT')});
if (date.getFullYear() === m.getFullYear())
return m.format('d M.');
return m.format('d M');
return m.format('LL');
}
case 'FULL':