Files
tom goriunovandGitHub 8554a956de Migrage to 24-hour time format (#3273)
* Migrate to 24h time format

Resolves #3240

* update screenshot
2026-02-10 12:01:26 +01:00

73 lines
1.6 KiB
TypeScript

// eslint-disable-next-line no-restricted-imports
import dayjs from 'dayjs';
import duration from 'dayjs/plugin/duration';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import minMax from 'dayjs/plugin/minMax';
import relativeTime from 'dayjs/plugin/relativeTime';
import updateLocale from 'dayjs/plugin/updateLocale';
import utc from 'dayjs/plugin/utc';
import weekOfYear from 'dayjs/plugin/weekOfYear';
import { nbsp } from 'toolkit/utils/htmlEntities';
const relativeTimeConfig = {
thresholds: [
{ l: 's', r: 1 },
{ l: 'ss', r: 59, d: 'second' },
{ l: 'm', r: 1 },
{ l: 'mm', r: 59, d: 'minute' },
{ l: 'h', r: 1 },
{ l: 'hh', r: 23, d: 'hour' },
{ l: 'd', r: 1 },
{ l: 'dd', r: 6, d: 'day' },
{ l: 'w', r: 1 },
{ l: 'ww', r: 4, d: 'week' },
{ l: 'M', r: 1 },
{ l: 'MM', r: 11, d: 'month' },
{ l: 'y', r: 17 },
{ l: 'yy', d: 'year' },
],
};
dayjs.extend(relativeTime, relativeTimeConfig);
dayjs.extend(updateLocale);
dayjs.extend(localizedFormat);
dayjs.extend(duration);
dayjs.extend(weekOfYear);
dayjs.extend(minMax);
dayjs.extend(utc);
dayjs.updateLocale('en', {
formats: {
llll: `MMM DD YYYY HH:mm:ss (Z${ nbsp }UTC)`,
lll: 'MMM D, YYYY H:mm',
},
relativeTime: {
s: '1s',
ss: '%ds',
future: 'in %s',
past: '%s ago',
m: '1m',
mm: '%dm',
h: '1h',
hh: '%dh',
d: '1d',
dd: '%dd',
w: '1w',
ww: '%dw',
M: '1mo',
MM: '%dmo',
y: '1y',
yy: '%dy',
},
});
dayjs.locale('en');
export default dayjs;
export const FORMATS = {
// the "lll" format with seconds
lll_s: 'MMM D, YYYY H:mm:ss',
};