Closed mglavall closed 4 years ago
var dayjs = require("dayjs")
var calendar = require('dayjs/plugin/calendar')
dayjs.extend(calendar)
dayjs().add(-1,'day').calendar()
result "Yesterday at 10:17 PM", so this should be correct
var dayjs = require("dayjs") var calendar = require('dayjs/plugin/calendar') dayjs.extend(calendar) dayjs().add(-1,'day').calendar()
result "Yesterday at 10:17 PM", so this should be correct
Because you aren't using the custom option, that's what I'm changing in the PR, try this:
var dayjs = require("dayjs")
var calendar = require('dayjs/plugin/calendar')
dayjs.extend(calendar)
dayjs().add(-1,'day').calendar(null, {
sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM )
nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM )
nextWeek: 'dddd', // The next week ( Sunday )
lastDay: '[Yesterday]', // The day before ( Yesterday )
lastWeek: '[Last] dddd', // Last week ( Last Monday )
sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 )
})
Oh, I see! Thanks.
Maybe updating the custom string instead of the comment will be better? https://github.com/iamkun/dayjs/blob/dev/src/plugin/calendar/index.js#L4
like
lastDay: [Yesterday at] h:mm A // The day before ( Yesterday at 2:30 AM )
Yes, I think that's good as well. Done :)
looks great, thanks
dddd, [Yesterday], and '[Last] dddd' doesn't show the time. Another possible fix would be to add the time to the format.