Repository navigation
fix(date): compute %U and %W week numbers like strftime - #958
Merged
Merged
Conversation
Owner
|
@all-contributors please add @web-orbit12 for code |
Contributor
|
I've put up a pull request to add @web-orbit12! 🎉 |
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
# [10.30.0](v10.29.0...v10.30.0) (2026-10-01) ### Bug Fixes * **base64_encode:** encode large input in browser builds ([#969](#969)) ([8aace78](8aace78)), closes [#967](#967) * **date:** compute %C and %y from the numeric year ([#961](#961)) ([e68514f](e68514f)) * **date:** compute %U and %W week numbers like strftime ([#958](#958)) ([0587ca8](0587ca8)) * trim custom characters by Unicode code point ([#955](#955)) ([3fe244f](3fe244f)) * **truncatewords:** ignore leading whitespace when counting words ([#954](#954)) ([65e200e](65e200e)) * **url_decode:** keep %2B as a literal plus when decoding ([#939](#939)) ([9af92f5](9af92f5)) ### Features * await promises returned by Drop.valueOf() ([#948](#948)) ([#953](#953)) ([#959](#959)) ([7dfa76b](7dfa76b))
|
🎉 This PR is included in version 10.30.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
%Uand%Win thedatefilter return the wrong week number for a large share of dates.getWeekOfYear(src/util/strftime.ts:25) has two problems:startDay(a Sunday with%W), "skip to startDay of this week" moves forward instead of back, so every Sunday is counted in the following%Wweek.7 - jan1.getDay() + startDay, which lands a week too late when January 1st is itself the start day, so those years (2006 for%U, 2007 for%W) come out one week short.This replaces it with the usual
strftimeformula,(yday + 7 - daysSinceStartDay) / 7with a 0-basedyday, which no longer depends on January 1st.Verification
Measured against the
liquidgem 5.14.0:%U %W2006-07-0527 2726 2627 272000-01-0201 0001 0101 002021-01-0301 0001 0101 002007-01-0100 0100 0000 01Every day from 2000-01-01 to 2030-12-30 (11,322 dates) compared with
strftime: before,%Uwas wrong on 1,461 dates and%Won 3,961; after, 0 withTZ=UTC,America/Los_AngelesandPacific/Kiritimati.TZ=Asia/Shanghai npm test(as intest.yml): 89 suites, 1671 tests, all passing.npm run lintexit 0. Reverting the change instrftime.tsfails the 3 new tests.