月份名稱
Locale#months
應為月份名稱陣列。
這需要 UpdateLocale
外掛才能運作
dayjs.extend(updateLocale)
dayjs.updateLocale('en', {
months: [
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
]
})
其他代幣處理
如果您需要更多處理才能計算月份名稱(例如,如果不同的格式有不同的語法),Locale#months
可以是一個具有以下簽名的函式。它應該總是傳回月份名稱。
dayjs.updateLocale("en", {
months: function (dayjsInstance, format) {
// dayjsInstance is the Day.js object currently being formatted
// format is the formatting string
if (/^MMMM/.test(format)) {
// if the format starts with 'MMMM'
return monthShortFormat[dayjsInstance.month()];
} else {
return monthShortStandalone[dayjsInstance.month()];
}
},
});