dayjs / dayjs-website

⏰Day.js website repo
http://day.js.org/
MIT License
66 stars 227 forks source link

RelativeTime thresholds customization #14

Closed tolgacesur closed 4 years ago

tolgacesur commented 4 years ago
// strict thresholds
var thresholds = [
  { l: 's', r: 1 },
  { l: 'ss', r: 59, d: 'second' }, // FIX : 'ss' is invalid format
  { 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: 29, d: 'day' },
  { l: 'M', r: 1 },
  { l: 'MM', r: 11, d: 'month' },
  { l: 'y' },
  { l: 'yy', d: 'year' }
]

https://day.js.org/docs/en/customization/relative-time#:~:text=strict%20thresholds this example is not working properly. Because the 'ss' format doesn't exist in locale file.

Example https://runkit.com/tolgacesur/5eeb8a2dd16b9e00131d4baf

PR : #13

iamkun commented 4 years ago

'ss' is supported in RelativeTime plugin, all you need to do is to update 'ss' in your locale config using UpdateLocale plugin.

iamkun commented 4 years ago

Also, I've updated the doc to make it more clear.