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
customParseFormat parses an incomplete datetime #701
Comments
I modified the third party code to not use customParseFormat and it correctly parses but the issue is that |
https://runkit.com/embed/d6xjrs5demn3 Hi, dayjs.utc() returns a UTC time in this test link |
It should be 0800 UTC as that is what is passed in. If you include customParseFormat it will be 0800 UTC. They function very differently. If you run my codesandbox you can uncomment or comment out customParseFormat and see how it is working in the 2 scenarios. I need a way to tell dayjs that the string passed in is UTC |
|
@iamkun I cannot see what plugins you do and don't have when you are just outputting the results. Below is what I am using and what I am seeing. They do not match when using customParseFormat and when not. This output for utc is incorrect because customParseFormat is not used. This one is wrong. dayjs.utc("10/18/2019 08:00", "MM/DD/YYYY HH:mm").toISOString(); // 2019-10-18T12:00:00.000Z -- Wrong. should be 0800Z Here using customParseFormat it treats the string as utc which is what it should do. dayjs.extend(utc); dayjs.utc("10/18/2019 08:00", "MM/DD/YYYY HH:mm").toISOString(); //2019-10-18T08:00:00.000Z We are just missing something in our communication so hopefully we can get on the same page. |
the second argument "MM/DD/YYYY HH: mm" is available only while using 'customParseFormat' plugin, otherwise, it will be ignored. And |
Okay, that still leaves my first post here which is what I was originally writing about
|
Still can't see the different |
If moment does the same thing then I believe that is a bug in moment too. How can a user type in a date time if they can't finish filling in the final value before it accepts it? How is that a valid datetime and why would it be set to 08:05? That is what I am getting at. |
I'll close this issue since it's been a while since it's been opened. Feel free to reopen if you have updates on this |
Describe the bug
Using the format "MM/DD/YYYY HH:mm" customParseFormat incorrect accepts the string "10/18/2019 08:5_" as 10/18/2019 08:05. Without customParseFormat dayjs correctly tags that as Invalid Date until the minutes are typed in.
dayjs("10/18/2019 08:5_", "MM/DD/YYYY HH:mm");
I would simply not use customParseFormat except it is used in a third party library so I cannot remove it.
https://codesandbox.io/s/dayjs-customparseformat-early-parse-upui5
Expected behavior
Invalid Date
Information
The text was updated successfully, but these errors were encountered: