Skip to content

fix(date_to_rfc822): use English day and month names - #974

Open
josefguenther wants to merge 2 commits into
harttle:masterfrom
josefguenther:fix/date-to-rfc822-locale
Open

josefguenther wants to merge 2 commits into
harttle:masterfrom
josefguenther:fix/date-to-rfc822-locale

Conversation

@josefguenther

Copy link
Copy Markdown
Contributor

date_to_rfc822 formats with %a, %d %b %Y %H:%M:%S %z, and %a and %b follow the locale option since #723, so with a non-English locale it renders names RFC 822 doesn't allow. This parses the date with en-US for that filter only. {{ "2023-11-14T22:13:20Z" | date_to_rfc822 }} with timezoneOffset: 0:

locale master this PR
en-US Tue, 14 Nov 2023 22:13:20 +0000 Tue, 14 Nov 2023 22:13:20 +0000
de-DE Di, 14 Nov 2023 22:13:20 +0000 Tue, 14 Nov 2023 22:13:20 +0000
fr-FR mar., 14 nov. 2023 22:13:20 +0000 Tue, 14 Nov 2023 22:13:20 +0000
ar-EG الثلاثاء, 14 نوفمبر 2023 22:13:20 +0000 Tue, 14 Nov 2023 22:13:20 +0000
none, on a de-DE host Di, 14 Nov 2023 22:13:20 +0000 Tue, 14 Nov 2023 22:13:20 +0000
fr-FR, date_to_long_string 14 novembre 2023 14 novembre 2023

date, date_to_string and date_to_long_string still follow locale.

The new test in test/integration/filters/date.spec.ts fails on master and passes here; the two existing date_to_rfc822 tests now also pass on a de-DE host, where they failed on master. npm run build, npm test (1701 tests) and npm run lint pass on Node 24.11.1.

Fixes #973

Written with AI assistance (Claude Code); I have reviewed the change.

date_to_rfc822 formats %a and %b, which follow the locale option, so
with a non-English locale (or none, on a non-English host) it rendered
names RFC 822 does not allow, such as "Di, 14 Nov 2023" for de-DE. It
now parses the date with the en-US locale. date, date_to_string and
date_to_long_string still follow the locale option.

Fixes harttle#973

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@harttle

harttle commented Oct 3, 2026

Copy link
Copy Markdown
Owner

There's preserveTimezone feature, we need more test cases to specify how it works with the the new parse/format branch.

@harttle harttle added the bug label Oct 3, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@josefguenther

Copy link
Copy Markdown
Contributor Author

Added three preserveTimezones cases under a non-English locale: with it the input's offset is kept, without it the date is converted to timezoneOffset, and a timestamp always uses timezoneOffset.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

date_to_rfc822 uses localized day and month names

3 participants