月份名称
Locale#months
应该是月份名称的数组。
¥Locale#months
should be an array of the month names.
This requires the
UpdateLocale
plugin to work
dayjs.extend(updateLocale)
dayjs.updateLocale('en', {
months: [
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
]
})
额外的令牌处理
¥Additional token processing
如果你需要更多的处理来计算月份的名称,(例如,如果不同的格式有不同的语法),Locale#months
可以是一个具有以下签名的函数。它应该总是返回一个月份名称。
¥If you need more processing to calculate the name of the month, (for example, if there is different grammar for different formats), Locale#months
can be a function with the following signature. It should always return a month name.
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()];
}
},
});