浏览代码

Adds weeks to relative time

main
Eric Amodio 4 年前
父节点
当前提交
4e45b9d210
共有 1 个文件被更改,包括 39 次插入0 次删除
  1. +39
    -0
      src/system/date.ts

+ 39
- 0
src/system/date.ts 查看文件

@ -2,9 +2,48 @@
import * as dayjs from 'dayjs';
import * as advancedFormat from 'dayjs/plugin/advancedFormat';
import * as relativeTime from 'dayjs/plugin/relativeTime';
import * as updateLocale from 'dayjs/plugin/updateLocale';
dayjs.extend(advancedFormat);
dayjs.extend(relativeTime);
dayjs.extend(relativeTime, {
thresholds: [
{ l: 's', r: 44, d: 'second' },
{ l: 'm', r: 89 },
{ l: 'mm', r: 44, d: 'minute' },
{ l: 'h', r: 89 },
{ l: 'hh', r: 21, d: 'hour' },
{ l: 'd', r: 35 },
{ l: 'dd', r: 6, d: 'day' },
{ l: 'w', r: 7 },
{ l: 'ww', r: 3, d: 'week' },
{ l: 'M', r: 4 },
{ l: 'MM', r: 10, d: 'month' },
{ l: 'y', r: 17 },
{ l: 'yy', d: 'year' },
],
});
dayjs.extend(updateLocale);
dayjs.updateLocale('en', {
relativeTime: {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: '%d hours',
d: 'a day',
dd: '%d days',
w: 'a week',
ww: '%d weeks',
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years',
},
});
export const MillisecondsPerMinute = 60000; // 60 * 1000
export const MillisecondsPerHour = 3600000; // 60 * 60 * 1000

正在加载...
取消
保存