Skip to content

fix(date): support %D, %F, %R, %r, %T and ISO week %G, %g, %V - #1009

Merged
harttle merged 1 commit into
harttle:masterfrom
zzoraemon043:fix/strftime-combinations
Nov 21, 2026
Merged

harttle merged 1 commit into
harttle:masterfrom
zzoraemon043:fix/strftime-combinations

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

date printed these Ruby strftime conversions literally:

{{ "2024-03-10T13:05:09" | date: "%F %T | %D %R %r" }}
{{ "2024-12-30" | date: "%G-W%V %g" }}

Before: %F %T | %D %R %r and %G-W%V %g
After: 2024-03-10 13:05:09 | 03/10/24 13:05 01:05:09 PM and 2025-W01 25 (same as Ruby)

The docs list only %Z and %q as differences from Ruby's flags, so templates using %F or %T got the raw text.

  • %D %F %R %r %T expand to their Ruby patterns through strftime, so the memory limit still applies. Width pads with spaces like Ruby (%12F is 2016-01-04).
  • %G %g %V are the ISO 8601 week-based year and week: weeks start on Monday and week 1 holds the first Thursday, so 2021-01-03 is 2020 W53 and 2024-12-30 is 2025 W01.

Added tests in src/util/strftime.spec.ts; the 7 new ones fail without the change. npm test (1773) and npm run lint pass. The date specs also pass with TZ set to Asia/Shanghai, America/New_York, Australia/Lord_Howe and Pacific/Kiritimati.

These Ruby strftime conversions were printed literally. The combinations
now expand like Ruby (%F is %Y-%m-%d, %r is %I:%M:%S %p, ...) and the
ISO 8601 conversions use Monday-based weeks where week 1 holds the
year's first Thursday.
@harttle
harttle merged commit 4c38560 into harttle:master Nov 21, 2026
14 checks passed
chris-monahan added a commit to chris-monahan/liquidjs that referenced this pull request Nov 29, 2026
- Add VMS date specifier (%v -> %e-%^b-%4Y) to strftime combinations
- Match "now" and "today" case-insensitively in date
- Return input unchanged when date format argument is an empty string

(Upstream harttle#1009 now covers %D, %F, %R, %r, %T, %G, %g and %V.)

Co-Authored-By: Gemini 4 Carbon (High) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants