Repository navigation
Conversation
… string. close apache#17186 `parseDate` read only the hour part of an offset such as `+05:30` or `-0330`, so times in zones with a non-zero minutes offset (India, Nepal, Newfoundland, central Australia, ...) were shifted by those minutes. Apply both the hours and the minutes of the offset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief Information
This pull request is in the type of:
What does this PR do?
Make
parseDateapply the minutes of a time zone offset such as+05:30, so date strings from zones that are not a whole number of hours from UTC are no longer shifted.Fixed issues
master)Details
Before: What was the problem?
parseDateinsrc/util/number.tsparses the string values used by time axes, time formatting and the calendar. For a string with an offset it didhour -= +match[8].slice(0, 3), which keeps the sign and hours of+05:30and drops the minutes. Every zone with a non-zero minutes offset was shifted by those minutes: India+05:30, Nepal+05:45, Newfoundland-03:30, central Australia+09:30, and others.2022-05-31 17:25:00+05:302022-05-31T12:25:00.000Z2022-05-31T11:55:00.000Z2024-03-21 10:00:00+09:302024-03-21T01:00:00.000Z2024-03-21T00:30:00.000ZThis is the 30-minute shift reported in #17186. With the issue's data in
+05:30, a point at 17:25 IST was drawn at 17:55.After: How does it behave after the fixing?
The sign of the offset is read once and applied to both its hours and its minutes, and both are passed to
Date.UTC, which normalizes out-of-range values.Zand whole-hour offsets give the same results as before. The doc comment typo'+8000'is now'+0800', and the comment gains a'+05:30'example.Added cases to the
parseDatetest intest/ut/spec/util/number.test.tsfor+05:30,+0530,+05:45,-03:30,-0930,-00:30, and a string without seconds. The expected values are written as UTC instants, so the test doesn't depend on the machine's time zone. The new cases fail without the change (30 minutes off). With the change,npm test,npm run lintandnpm run checktype(afternpm run build:lib, as in CI) pass.Document Info
One of the following should be checked.
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
test/ut/spec/util/number.test.ts(parseDate).Merging options
Other information
I used Claude Code to write this change.