Skip to content

fix(time): keep the minutes of a time zone offset when parsing a date string. close #17186 - #21814

Open
b84330808 wants to merge 1 commit into
apache:masterfrom
b84330808:claude/focused-bohr-ggpvwh
Open

b84330808 wants to merge 1 commit into
apache:masterfrom
b84330808:claude/focused-bohr-ggpvwh

Conversation

@b84330808

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • 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

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.

  • 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.

… 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>
@echarts-bot

echarts-bot Bot commented Oct 31, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

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.

@plainheart plainheart added this to the 6.2.0 milestone Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants