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.
Refactor dateToRfc822 to use local timezone:
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.timeZoneName
is preferable, and more accurate.I created a RFC822 RegEx101 tool for checking the pub date format: https://regex101.com/library/KGSAUY