moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.05k stars 728 forks source link

fromFormat ZZZZ doesn't parse UTC, returns null #1552

Closed ozten closed 7 months ago

ozten commented 7 months ago

Describe the bug I am trying to parse a string like 11/15/23 00:51 UTC. I get { Invalid, reason: unparsable }.

To Reproduce These fail when added to test/datetime/tokenParse.test.js

 expect(DateTime.fromFormat("UTC", "ZZZZ").zoneName).toBe('UTC');  
 expect(DateTime.fromFormat('11/15/23 00:51 UTC', 'LL/dd/yy T ZZZZ').toMillis()).toBe(1700009460000);

These both fail.

Actual vs Expected behavior

DateTime.fromFormat should support ZZZZ formatting.

Desktop (please complete the following information):

Note: This is happening in NodeJS process as well as in the browser.

Additional context

diesieben07 commented 7 months ago

Parsing has a separate table of tokens from formatting. This is due to limitations of the Intl API that Luxon uses, this is explained here.