b84330808 opened a new pull request, #21814:
URL: https://github.com/apache/echarts/pull/21814

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   
   
   ### What does this PR do?
   
   Make `parseDate` apply 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
   
   - #17186: [Bug] Echarts are plotted wrongly for type time, if the time data 
is given with timezone offset (closed by the stale bot, but still reproducible 
on `master`)
   
   
   ## Details
   
   ### Before: What was the problem?
   
   `parseDate` in `src/util/number.ts` parses the string values used by time 
axes, time formatting and the calendar. For a string with an offset it did 
`hour -= +match[8].slice(0, 3)`, which keeps the sign and hours of `+05:30` and 
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.
   
   | Input | Before | Expected |
   | --- | --- | --- |
   | `2022-05-31 17:25:00+05:30` | `2022-05-31T12:25:00.000Z` | 
`2022-05-31T11:55:00.000Z` |
   | `2024-03-21 10:00:00+09:30` | `2024-03-21T01:00:00.000Z` | 
`2024-03-21T00:30:00.000Z` |
   
   This 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. `Z` and 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 `parseDate` test in `test/ut/spec/util/number.test.ts` 
for `+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 lint` and `npm 
run checktype` (after `npm run build:lib`, as in CI) pass.
   
   
   
   ## Document Info
   
   One of the following should be checked.
   
   - [x] This PR doesn't relate to document changes
   - [ ] The document should be updated later
   - [ ] The document changes have been made in apache/echarts-doc#xxx
   
   
   
   ## Misc
   
   ### Security Checking
   
   - [ ] This PR uses security-sensitive Web APIs.
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   `test/ut/spec/util/number.test.ts` (`parseDate`).
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### Other information
   
   I used Claude Code to write this change.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to