-
-
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
customParseFormat strict mode bug #929
Comments
We have the same problem. I created this codesandbox example to reproduce the issue |
R.I.P 👌 |
I've looked into the code and so far I see only two options for how this bug could be fixed:
|
Bug confirmed. Strict mode does not work good with parsing timezone (ZZ) I'm looking for a way to solve it. |
I am trying to migrate some code from moment to dayjs, and this strict check is a big problem for me :(, any idea how to solve it? |
@iamkun is there any known workaround available right now? Or do you eventually have an estimated time until when this can be looked into? Thanks in advance |
@iamkun I've created a pull request which tries to fix this issue (#1467). The following has been done to fix it: The parseFormattedInput function returns a UTC object for dates with timezones. When using dayjs().format() it usually formats the date with the current timezone. This fix manually removes the current timezone's offset and manually adds the originally parsed offset. Then the timezone part (+/-xx:xx or +-xxxx) will be removed from both strings and the timestamp without the timezone can be compared correctly. |
Any updates on this? Looks like the PR #1467 has conflicts which need to be resolved. Kinda strange that dayjs can't handle |
@iamkun is there anything else we can do to help get this pull request merged? |
@iamkun Just a friendly reminder :) |
any news about the problem? |
Is there any progress for this? |
any news about the timezone parsing issue? It will be great to use it properly as I'm migrating from |
any news? 😅 |
Describe the bug
Using the format string "YYYY-MM-DD HH:mm:ss ZZ", parsing certain strings returns Invalid Date when it should return a date:
where
bad
is:The parsing is successful if strict mode is not used. The problem seems to be in the
customParseFormat.js
line:where the date that the plugin has parsed is not matching the default output from
dayjs.format()
. In the above case:but the same bug will effect parsing any date where the timezone doesn't match whatever local timezone/dst dayjs uses. eg. "2018-03-01 00:01:00 +0600", "2018-04-01 00:01:00 -0200", etc.
Expected behavior
bad
should be a valid date object.Information
The text was updated successfully, but these errors were encountered: