-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Provide way to specify multiple formats when creating a date in UTC. #1596
Comments
Think we should change the line 18 in
to:
|
Sorry for not responding sooner as I completely missed the notification about your message. Anyhow, I don't think that proposed solution would help. The issue is that I need to be able to specify multiple formats, meaning that it needs to support a list (i.e. array type). The issue isn't about missing the ability to specify the locale (although others may find that helpful). |
I have the same issue here, it'd be really nice to have the same parameters as the This is my workaround :
|
I have traced down the issue: the problem is caused by the 'strict' parameter. The plugin customParseFormat tries to validate that the format of the input string has exactly the same format as one of the format strings by formatting the parsed date using the given format parameters and requires the result to match the input string. To solve the issue, the line |
Thanks. All the bugs will be tracked on v1.x. |
Added tests for more scenarios (e.g. issue iamkun#1596)
Added tests for more scenarios (e.g. issue iamkun#1596)
Here's what I ended up doing:
|
If trying to parse a date in which you also need to enable it validates correctly (i.e. using strict mode), you can do so with the following
However, if using the UTC plugin, it doesn't seem to allow specifying multiple formats so I can only do
It would be great the behavior of utc could be extended to support multiple formats as well. Or if anyone knows a workaround to get strict validation and UTC both working together, I'd love to hear it.
The text was updated successfully, but these errors were encountered: