日历
Locale#calendar
应具有以下格式字符串。
¥Locale#calendar
should have the following formatting strings.
This requires the
UpdateLocale
plugin to work
dayjs.extend(updateLocale)
dayjs.updateLocale('en', {
calendar: {
lastDay: '[Yesterday at] LT',
sameDay: '[Today at] LT',
nextDay: '[Tomorrow at] LT',
lastWeek: '[last] dddd [at] LT',
nextWeek: 'dddd [at] LT',
sameElse: 'L'
}
})
每个 Locale#calendar
键也可以是一个回调函数,其范围是当前 Day.js 对象,第一个参数是描述现在的 Day.js 对象。它应该返回一个格式化字符串。
¥Each of the Locale#calendar
keys can also be a callback function with the scope of the current Day.js object and first argument a Day.js object that depicts now. It should return a formatting string.
function callback (now) {
return '[hoy a la' + ((this.hour() !== 1) ? 's' : '') + ']' + now.format();
}