Fix week 0 for early January dates - #4
Open
dyk1454683243-sudo wants to merge 1 commit into
Open
dyk1454683243-sudo wants to merge 1 commit into
dyk1454683243-sudo wants to merge 1 commit into
Conversation
Math.floor(days / 7) yields 0 for dates in the first partial week (for example 3 January 2017). Adding 1 keeps Sunday-start numbering and matches this package's simple 1-based API. Fixes datetime#3 Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
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.
Fixes #3.
week()usedMath.floor(days / 7), so any date in the first Sunday-start week of the year (a value in[0, 7)) returned"0". The reporter hit this on 3 January 2017.This keeps the existing Sunday-start helper (from #1) and makes the result 1-indexed with
floor + 1, matching this package’s simple API and other datetime helpers that treat month numbers as 1-based. It is not a switch to ISO 8601 week numbering.Behavior
"0""1""0""1""1""2""10""11"Tests
Regression coverage uses fixed
Dateinputs, including2017-01-03, January 1 when it is not Sunday, and a mid-year date so numbering stays consistent after week 1.