Calendar format returns wrong date
See original GitHub issueHello!
I have the following snippet:
import calendar from 'dayjs/plugin/calendar';
dayjs.extend(calendar);
return dayjs().calendar(dayjs(date), {
sameDay: '[Today]',
nextDay: '[Tomorrow]',
nextWeek: 'dddd',
lastDay: '[Yesterday]',
lastWeek: '[Last] dddd',
sameElse: 'DD/MM/YYYY',
});
The problems , in my opinion, are :
- if the date falls under the sameElse category i get the date of today ( since today is 16/11/2020, i get 16/11/2020 for all dates that fall under sameElse)
- all dates under next and last are inverted - meaning if i choose 17/11/2020, i get yesterday, and i if choose 15/11/2020, i get tomorrow
- also, for dates such as 18/11/2020,19/11/2020 i get last Monday instead of Wednesday or Thursday, and for dates such as 14/11/2020 i get Monday instead of last Sunday
If I’m missing something from the documentation, please let me know, but in my opinion this isn’t the right behaviour for this function.
Thank you for your time!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
Java Calendar returns wrong date
MONTH) throws an exception, when the month isn't the same. My start date is 1/12/2017 and enddate is 31/12/2017. so the month should...
Read more >Date in Swift printed is wrong
This is because the date is stored in Swift as UTC time, i.e. as at longitude 0.0 - which used to be called...
Read more >Moment.js | Docs
If the string or format you are asking to change is reflected in the CLDR, ... is not able to be parsed with...
Read more >Format Function
Returns a Variant (String) containing an expression formatted according to ... If the calendar is Hijri, all date format symbols (for example, dddd,...
Read more >System.date.format() returns wrong calendar week - Ignition
Hi there, i am calculating the calendar week from a timestamp in a property transform script. The script is not returning what I...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I solved this issue by switching the two dates :
I don’t know if the issue is about the documentation or the calendar plugin.
Any update on this? I’m patching the plugin for now similar to what @borie88 helpfully suggested above. Just curious if this will make it into the library.
Here’s a reproduction if anyone else encountering this issue wants to look: https://codesandbox.io/s/billowing-dream-7obed