-
Notifications
You must be signed in to change notification settings - Fork 648
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
new Date('MMM DD, YYYY HH:MM PM') format is not supported #1519
Comments
|
|
|
|
What's the exact error you're seeing? |
when i am doing this |
Passing over to Hermes. @neildhar is this Intl related? |
Thanks for the report. This doesn't seem related to There's many different kinds of Date string inputs, and which inputs are accepted across which engines can vary significantly, so using the standard-specified input format to Date is the best way to ensure you have consistent behavior. I can reproduce that It's likely we could add support for the format that doesn't include the weekday. We will review pull requests to add new |
So, to recap: the spec does not require this format, and Hermes has never supported it. However JSC and v8 engines do support it. For now we view this as a low priority enhancement and are we unlikely to work on it soon, but we are happy to review PRs adding it. |
@tmikov @cortinico Thank you for the clarification regarding the spec and engine support differences. While I understand that this format is not explicitly required by the spec, it is still widely used and expected by many developers due to its support in major JavaScript engines like JSC and V8. As a result, many React Native applications that rely on these engines are likely to encounter unexpected behavior when transitioning to Hermes, leading to bugs that are difficult to track down, especially for developers unfamiliar with engine differences. Given React Native’s push towards Hermes as the default engine, maintaining compatibility with commonly used formats would reduce friction for developers and help smooth the transition. A significant number of apps may already rely on this behavior, and breaking it without a clear alternative creates additional challenges in upgrading and maintaining apps. I believe ensuring compatibility with formats supported by other major engines should be considered a higher priority, as it affects developer experience, consistency, and ease of migration to Hermes. I would kindly urge the team to reconsider the priority of this issue. |
Description
In previous versions of React Native, I was able to successfully create a Date object using a string in the following format: "Sep 12, 2024 04:30 PM". For example:
new Date('Sep 12, 2024 04:30 PM');
However, in the current version of React Native, this same code now results in an Invalid Date error.
This format worked seamlessly in earlier versions, and it’s a commonly used date string format in many applications. I believe this change may have introduced a regression in how date strings are parsed.
Steps to reproduce
Steps to Reproduce:
Expected Behavior:
The Date object should correctly parse the string and create a valid Date instance, as it did in previous versions.
Environment:
React Native Version: 0.75.2
React Native Version
0.75.2
Affected Platforms
Runtime - Android, Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
not
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: