Calendar
Locale#calendar
應具有下列格式化字串。
這需要 UpdateLocale
外掛才能運作
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 物件。它應傳回格式化字串。
function callback (now) {
return '[hoy a la' + ((this.hour() !== 1) ? 's' : '') + ']' + now.format();
}