Repository navigation
fix(en): resolve "last/next weekday" to the adjacent working day - #679
Open
Enesuygurs wants to merge 1 commit into
Open
Enesuygurs wants to merge 1 commit into
Enesuygurs wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
"last weekday" and "next weekday" give the wrong date on 4 of the 7 days of the week. The existing tests only use Friday and Saturday as the reference date, and both happen to work.
With a reference of Monday 2024-10-21:
"next weekday" is also a week late from Tuesday, Wednesday and Thursday. For example, Wed Oct 23 gives Thu Oct 31 instead of Thu Oct 24.
There are two causes, both in the "weekday" branch of
ENWeekdayParser:(weekday % 5) + 1is meant to wrap Monday back to Friday, but in JS-1 % 5is-1, so the result is Sunday. It is now((weekday + 5) % 5) + 1.createParsingComponentsAtWeekday. There, "next Tuesday" said on a Monday means Tuesday of the following week. For "weekday", the "next" modifier is now passed as "this", which counts forward to the day already computed. The Friday, Saturday and Sunday results don't change.I added Monday and Wednesday reference cases to the existing "Casual 'weekday' mentioning" test. They fail before this change and pass with it, and the full suite passes (753 tests).