-
Notifications
You must be signed in to change notification settings - Fork 729
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
DateTime.fromFormat is not able to correctly parse the result of DateTime.toFormat() #857
Comments
Odd. What does |
'en-GB' |
Managed to reproduce this at this codesandbox (with the system locale being en-GB).
The issue is that, in the browser, In using
But 3 / 4 appear to be switched as it stands. |
I've managed to get a unit test for this up and running (by moving I'm a little nervous about it though, as I assume that flag was explicitly set to true for a reason. |
Forcing the parse to default to EN is indeed on purpose. Imagine you're building a web app and you're requesting data off of some backend, and it formats dates like, say, However, the localized macro tokens really should localized with the default locale. I had thought they did |
I confirm that passing the locale explicitly in the options resolves this issue. |
I think if I was expecting US formatted dates from a backend, I'd expect to have to specify en-US explicitly in If that's the expected behaviour though, I guess this one can be closed? |
Hello I'm facing the same issue with luxon
|
@patriceo |
Hi @diesieben07, thanks for pointing this out, I missed it. Do you know if there is any plan to change this implementation so the two methods get symmetrical? I didn't check the implementation but the standard Date class can parse some formatted dates with explicit timezone https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse I don't see any option to parse a DateTime with time-zone with the current version. Thanks! |
What it can parse is offsets, but Luxon already offers this (via the |
To add to that: |
The following code results in an invalid DateTime:
error on the resulting DateTime object:
I'm using firefox 84.0.2 on windows 10, lang in browser set to en-GB, windows region format set to Polish, windows display language set to en-GB, windows apps and websites land set to en-US.
The text was updated successfully, but these errors were encountered: