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

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### What does this PR do?
   
   Formats hour 0 (midnight) as `12` instead of `0`/`00` for the 12-hour `{h}` 
and `{hh}` time template placeholders.
   
   ### Fixed issues
   
   N.A.
   
   ## Details
   
   ### Before: What was the problem?
   
   The docs describe `{hh}` as `01-12` and `{h}` as `1-12`, but at midnight 
`echarts.time.format` (also used by time axis labels and tooltip templates) 
produced `00`/`0`:
   
   ```js
   echarts.time.format(new Date('2023-12-19 00:05:00 UTC'), '{hh}:{mm} {A}', 
true);
   // '00:05 AM', expected '12:05 AM'
   ```
   
   The 12-hour value was computed as `(H - 1) % 12 + 1`. In JavaScript `-1 % 
12` is `-1`, so `H = 0` gave `0`.
   
   ### After: How does it behave after the fixing?
   
   The 12-hour value is now computed as `H % 12 || 12`, so midnight gives 
`12:05 AM`. Noon (`12`) and all other hours are unchanged. No built-in default 
template uses `{h}`/`{hh}`, so only user-provided templates are affected.
   
   ## 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
   
   Added a unit test in `test/ut/spec/util/time.test.ts` covering midnight, 
noon and 23:00 with `{hh}`, `{h}` and `{A}`. It fails before the fix and passes 
after.
   
   Validation: all 227 unit tests pass, and `npm run lint` and `npm run 
checktype` pass.
   
   ### Merging options
   
   - [x] Please squash the commits into a single one when merging.
   
   ### Other information
   


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