Pass rc.weekstart to libshared for ISO8601 weeknum parsing if "monday" #3654
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Libshared
master
branch has been updated to have some consideration ofDatetime::weekstart
: date parsing (in particular week/day numbers) will behave differently depending on whether that value is 0 or 1 (see GothenburgBitFactory/libshared#81).Previously, that code always behaved as the new code does when
weekstart=0
when parsing dates (weekstart was used only fortask calendar
). The new code will use ISO8601 date parsing if that value is 1, which it is initialized to in the top of the file. Since this will cause a change in behavior, we can least surprise users by initializing it from user config, which is done inContext::StaticInitialization()
.The hardcoded default rcfile sets weekstart to Sunday (0, the existing behavior) so only users that set
rc.weekstart=monday
explicitly will see new ISO8601 date parsing behavior, everyone else should see the same behavior as before.Note: the week shortcuts (
sow
,sonw
, etc) will still always use Monday weeks, regardless of weekstart, until the additional work mentioned in #3623 is done. That will be left for a part2 some time later. We can track that work in #3629.Old code did not distinguish weekstart, and always used Sunday week parsing:
The date 2013-12-01 is actually in week 48 for both Sunday and Monday-based weeks, and week 49 only begins on the 2nd, which is seen correctly in ISO-8601 weeks:
This is reflected in the new code when Monday is selected as the weekstart:
The old code is left intact when Sunday-based weeks are used. It seems to be Taskwarrior's own definition of weeks, since it differs from
strftime()
expansion%U
, as noted above. Nonetheless, the Sunday behavior was left unchanged from previous Taskwarrior versions, and that remains the default. For correctness, it is recommended for users to configure Monday-based weeks, which would now be determined using an ISO-8601 standard algorithm.Please apply, thanks.
eow
does not respect weekstart #3629 (part1 done for parsing; more work needed)