-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Hello,
It could be a good idea to add callbacks as possible values to Calendar format.
Like momentjs does since 2.14.0 : look here.
Exemple:
With arrow function:
dayjs("2020-02-26").calendar(null, {
sameElse: (now, self) => {
const d = self.diff(now);
if (d > 0) return "After";
else return "Before";
}
});With classic function:
dayjs("2020-02-26").calendar(null, {
sameElse: function (now) {
const d = this.diff(now);
if (d > 0) return "After";
else return "Before";
}
});We can pass a function which take as parameter the date given to calendar call (here null so now) and to be fully compatible with momentjs we can use this instead of the second parameter to access the base instance (here dayjs("2020-02-26")).
Thanks ;)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request