You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also same problem with last 3 days in 2025 if it can help somehow (but not with any last days in 2023 or 2022) I've closed my issue about that by my mistake, so don't rely on it. Thanks for checking and reopenning!
The error in the python/babel library is related to the incorrect use of the YYYY format in the format string "YYYY-MM-dd (cccc)". In the Babel library (and other date-handling libraries like Moment.js), YYYY represents the week year, not the calendar year. The week year can differ from the calendar year, especially in the last days of December or the first days of January, if the week transitions into the next year.
Why does this happen?
Week year (YYYY) is determined by ISO weeks. If December 30 or 31 fall into the first week of the next year, YYYY will return the next year.
Calendar year (yyyy) always returns the current year, regardless of the week.
How to fix it?
Use yyyy instead of YYYY in the format string to get the correct calendar year:
Examples:
YYYY-MM-dd (cccc) → 2025-12-30 (Monday) (incorrect, uses the week year)
yyyy-MM-dd (cccc) → 2024-12-30 (Monday) (correct, uses the calendar year)
Why does it work with format="long" and format="short"?
When using built-in formats like "long" or "short", the Babel library automatically selects the correct year format (yyyy), so the issue does not occur.
Conclusion:
The error is caused by using YYYY instead of yyyy. To correctly display the calendar year, always use yyyy in custom formats.
Related to #1171.
Note
long
/short
etc. isn't affected, just the custom formats.The text was updated successfully, but these errors were encountered: