-
Notifications
You must be signed in to change notification settings - Fork 300
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
fix: iso week usage #1956
base: main
Are you sure you want to change the base?
fix: iso week usage #1956
Conversation
Fava appears to use ISO 8601 weeks (e.g. `2025-W01`), but unfortunately does so incorrectly due to a mismatch between ISO 8601 and Gregorian calendar week definitions. ISO 8601 defines precisely how to handle weeks, namely, that the first week of a year is the week that contains 4 January. This definition results in some occasional mismatches with the Gregorian calendar such as: - The first week of 2025 starts on 30 December 2024 - 3 January 2021 belongs to Week 53 of 2020 Fortunately, the fix is straightforward as `strftime` provide[^posix]: - `%G` for the week-based year - `%V` for the week number of the year (with no 'week 0' as `%W` can return). This change will ensure that there is no ambiguity on weeks that straddle the new year, though at the cost of introducing occasional off-by-one errors compared to previously generated data. [^posix]: See [POSIX.1-2024](https://pubs.opengroup.org/onlinepubs/9799919799/functions/strftime.html) Signed-off-by: JP-Ellis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR - this came up in #1805 and I agree with switching to ISO week numbers. The current behaviour is as documented in the help page on the filters and that will have to be updated as well, could you take a look at that? Other than that, the PR looks good
Amazing! Sure happy to look at the docs too. I'll probably do this tomorrow or Monday. |
Docs have been updated 👍 |
Add docs explaining how ISO 8601 week dates are calculated, and give examples of when they differ slightly from what one might naively expect looking at a Gregorian calendar. Signed-off-by: JP-Ellis <[email protected]>
1e234b4
to
5d0fb3d
Compare
Any further updates needed before this can be merged? |
Fava appears to use ISO 8601 weeks (e.g.
2025-W01
), but unfortunately does so incorrectly due to a mismatch between ISO 8601 and Gregorian calendar week definitions.ISO 8601 defines precisely how to handle weeks, namely, that the first week of a year is the week that contains 4 January. This definition results in some occasional mismatches with the Gregorian calendar such as:
Fortunately, the fix is straightforward as
strftime
provide1:%G
for the week-based year%V
for the week number of the year (with no 'week 0' as%W
can return).This change will ensure that there is no ambiguity on weeks that straddle the new year, though at the cost of introducing occasional off-by-one errors compared to previously generated data.
Fixes #1805
Footnotes
See POSIX.1-2024 ↩