-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default calendar formats #805
Comments
You can also pass specifying calendar output formats as the second parameter. |
Well, actually I have to pass the exact same calendar format to a lot a different place in my code. To avoid code duplication I would like to setup a default formats to dayjs for calendar plugin so, I just have to call |
Oh, I see. Maybe there's a better way. You can update the locale config like this. var dayjs = require("dayjs")
var calendar = require('dayjs/plugin/calendar')
var updateLocale = require('dayjs/plugin/updateLocale')
dayjs.extend(updateLocale)
dayjs.extend(calendar)
dayjs.updateLocale('en', {
calendar: {
sameDay: '[Today at] h:mm A[ your format]',
nextDay: '[Tomorrow][ your format]',
nextWeek: 'dddd[ your format]',
lastDay: '[Yesterday][ your format]',
lastWeek: '[Last] dddd[ your format]',
sameElse: 'DD/MM/YYYY[ your format]'
}
})
dayjs().calendar(dayjs('2008-01-01')) |
Awesome, I’ll try that but it’s appear to be what I would like to achieve and in addition with i18n spec ! Thanks ! |
fixed |
Hello,
I'm looking to change the default formats of the
Calendar
plugins.Actually, I'm forced to override the
calendar
method like this:Which does not respect our code standards.
Is there any other options ?
Thanks,
The text was updated successfully, but these errors were encountered: