RangeError: Format string contains an unescaped latin alphabet character `z`
See original GitHub issueI’m getting this RangeError when trying to parse a date string like this 2020-11-09 6:05pm GMT using z for the timezone as noted in the unicode date symbol field table.
Similar to https://github.com/date-fns/date-fns/issues/1473 except this is about parsing rather than formatting.
I realize that the docs for parse don’t list z as a pattern but using x or X or xx etc doesn’t work as well. As an aside, the docs seem to imply that the functions support all of the patterns in the unicode standard – plus additions, but that doesn’t seem to be the case.
I created a sandbox to demonstrate the specific error here: https://codesandbox.io/s/date-fns-parsing-issue-qkyht
Is this format not possible to parse?
Thanks ahead of time for the help!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Can't resolve RangeError: Format string contains an ... - GitHub
I found if I use @date-io/date-fns2.x , there will truely occur the problem 'Can't resolve RangeError: Format string contains an unescaped latin ......
Read more >Cannot get material-ui datepicker to work - Stack Overflow
Uncaught RangeError: Format string contains an unescaped latin alphabet character n. you have to downgrade to @date-io@^1.3.13.
Read more >date-fns@2.29.3 - runpkg
The characters in the format string wrapped between two single quotes ... @throws {RangeError} format string contains an unescaped latin alphabet character.
Read more >Format string contains an unescaped latin alphabet character `z`
I'm getting this RangeError when trying to parse a date string like this 2020-11-09 6:05pm GMT using z for the timezone as noted...
Read more >Format string contains an unescaped latin alphabet character `n`
RangeError : Format string contains an unescaped latin alphabet character `n`. Comment. 3.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@scscgit I like the idea of a page to compare token compatibility between the parse and format functions, making note of it.
Actually, it looks like
zinformatwas implemented to behave likeO… so that’s going to be a problem for interop and a breaking change if it gets fixed.https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
@vadimpopa Glad you figured out an approach, and yes I imagine this would get very unwieldy for several languages.
Little bonus code snippet update that will scale much better if a larger list of offsets is needed.
And a few resources: https://www.timeanddate.com/time/zones/ https://en.wikipedia.org/wiki/List_of_tz_database_time_zones https://www.iana.org/time-zones