Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor dateToRfc822 to use local timezone #45

Merged
merged 3 commits into from
Jun 9, 2024

Conversation

fliptopbox
Copy link
Contributor

@fliptopbox fliptopbox commented May 12, 2024

Refactor dateToRfc822 to use local timezone:

  • Simplify the RFC822 method to use Intl.DateTimeFormat() API, which eliminates the need for hard coded Month and Day arrays, since the API has those features built into its formatting options.
  • Also the previous version hard codes the timezone (as +0000), which is awkward for European implementations, where using the timeZoneName is preferable, and more accurate.
  • And finally update the unit test to assert the RFC822 string format as proposed, instead of checking the return value of the function against a known artifact.

I created a RFC822 RegEx101 tool for checking the pub date format:
https://regex101.com/library/KGSAUY

@zachleat zachleat added this to the Eleventy RSS Plugin v2.0 milestone Jun 9, 2024
@zachleat zachleat merged commit a78cfeb into 11ty:master Jun 9, 2024
@zachleat
Copy link
Member

zachleat commented Jun 9, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants