-
Notifications
You must be signed in to change notification settings - Fork 742
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 Fails to Parse Time #1382
Comments
It sounds like others are experiencing this issue when updating to Node 18 as well: #1364 (comment) |
This is behaving exactly as described in the documentation, imho. This is also mentioned in the documentation:
|
@diesieben07 It's a breaking change nodejs/node#46123 I think it should be handled by this lib, rather than users. One more thing, the output of API in different browser should be same. It should be handled by this lib. |
toLocaleString is specifically also dependent on the underlying implementation. That allows Luxon to be smaller in size than e.g. moment, which has to ship all the locale data. All that If you rely on specific output from toLocaleString you are imho misusing the locale API. This also applies to using the locale-dependent format tokens like So: This is not something to be "handled". You are using the wrong tool. |
@diesieben07 Thanks for the reply. But if you use |
You can't have both. Either you want the local format, then you have to accept it as is from the underlying system (including the fact that ICU now says that a narrow space should be used) or you have to provide your own formats. |
No, I don't agree. It's ridiculous cannot have both locale and regional format. |
Is there any maintainer active here? |
I'd be curious how you would like Luxon to handle this instead of the current system. |
Didn't had the time to wait for a merge, there I have replace my string : |
@shinnqy @derekhubbard Would an option |
#1369 has been merged. The next version of Luxon will treat non-breaking white-space equally when parsing macro-tokens like |
@diesieben07 Also running into the same issue after updating Chrome 109 to 110. When will the next version be released? |
That would be up to @icambron, I don't have permissions to do releases. |
@diesieben07 I understand that this will be fixed once the next version is released but just out of curiosity, why does
but why wouldn't this work?
I guess I would expect that since I formatted the datetime on Chrome, it would use that narrow no-break space character character that it is expecting when parsing the string using |
@ccmetz My guess is that your browser is on a different locale than |
Describe the bug
Using
DateFormat.fromFormat
to parse a time value fails to parse the time successfully, resulting in an invalidDateTime
object.This worked as expected until updating my browser from Chrome 109 to 110.
Parsing the same time value in Safari 16.3 and Firefox 110 works as expected.
To Reproduce
The output of the console logs above are:
Actual vs Expected behavior
The time format in the example above (
1:07 AM
) should be successfully parsed as a validDateTime
object.Desktop (please complete the following information):
Additional context
It's not clear yet whether this is Chrome bug or an issue with Luxon, but starting here in the hopes that you will be able to help me research it more. Thanks in advance!
The text was updated successfully, but these errors were encountered: