Repository navigation
fix(date): compute %C and %y from the numeric year - #961
Merged
Merged
Conversation
Both were sliced from the year string, so years with other than four digits gave the wrong century and two-digit year, and %y was a string that the - and _ flags could not unpad. Compute them arithmetically and pad them to two digits, matching Ruby's strftime.
Owner
|
@all-contributors please add @youdie006 for code |
Contributor
|
@youdie006 already contributed before to code |
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.
%Cand%yslice the year string (src/util/strftime.ts:46and:113), so they are wrong for years that are not four digits, and%yreturns a string that the-and_flags cannot unpad.{{ d | date: "%C|%y|%-y|%_y" }}:strftime20|05|05|0520|05|5| 520|05|5| 520|16|16|1699|9|9|909|99|99|9909|99|99|99This computes both from the numeric year and adds
CandytopadWidths, as #958 did for%U/%W. Plain%Cand%youtput for four-digit years is unchanged; the visible change there is%-y/%_yfor years like 2005.The new test in
src/util/strftime.spec.tsfails on master and passes here.npm test(TZ=Asia/Shanghai, 1672 tests; src and filter tests also under America/New_York),npm run lint,tsc --noEmitandnpm run buildpass on Node 22.Written with AI assistance (Claude); I have reviewed the change.