Closed Kydlaw closed 1 year ago
As documented in the table of tokens, ZZZZZ
is not a valid parsing token. Luxon can only parse time zones from their IANA names (or from an offset, like you are already doing), this uses the token z
. The reason for this is that there is no browser API to parse "human readable" time zone names and those names are not even consistent or unique.
This specific limitation is also discussed here: https://moment.github.io/luxon/#/parsing?id=limitations
Is there a viable workaround for this? I'm dealing with 3rd party data that uses the abbreviated timezone eg BST
Unfortunately the only real option you have is to ship your own mapping of abbreviated zones to proper time zone names and do the replacement manually before passing it in to Luxon or otherwise. I'm not 100% sure where you'd find this, but most likely either in the IANA Time Zone Database or maybe in Unicode's ICU.
Describe the bug
Parsing of the string "Tue Jan 24 2023 23:59:39 GMT+0100 (Central European Standard Time)" using "EEE MMM dd yyyy HH:mm:ss 'GMT'ZZ (ZZZZZ)" fails
To Reproduce
Actual vs Expected behavior Currently it returns an invalid DateTime I expected the
.fromFormat()
function to return a DateTime object containing the information from the string.Desktop (please complete the following information):
Additional context Add any other context about the problem here.