Skip to content
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

[Bug] Date Format {yy} doesn't match with documentation #17063

Closed
Woonters opened this issue May 18, 2022 · 2 comments · Fixed by #17064
Closed

[Bug] Date Format {yy} doesn't match with documentation #17063

Woonters opened this issue May 18, 2022 · 2 comments · Fixed by #17064
Labels
bug en This issue is in English

Comments

@Woonters
Copy link
Contributor

Version

5.3.2

Link to Minimal Reproduction

https://codesandbox.io/s/yy-date-error-rqmsup

Steps to Reproduce

Use echarts.date.format with a format string containing {yy} on a date with a single digit year (2000 to 2009)
echarts.time.format( "2003-05-04 10:56:30", "Echarts output: {yy} " );

Current Behavior

Returns a string with no padding

Expected Behavior

According to https://echarts.apache.org/en/option.html#timeline.label.formatter:
{yy} -> 00-99
this implies that the number should be padded to be size 2 e.g. 2000 goes to 00, 2003 goes to 03

Environment

No response

Any additional comments?

A current fix could be changing

.replace(/{yy}/g, y % 100 + '')

( .replace(/{yy}/g, y % 100 + ''))
to:
.replace(/{yy}/g, pad( y % 100 + ''),2)

@Woonters Woonters added the bug label May 18, 2022
@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. waiting-for: community labels May 18, 2022
@plainheart
Copy link
Member

Thanks for your feedback. Would you mind opening a PR to fix this issue?

@plainheart plainheart removed the pending We are not sure about whether this is a bug/new feature. label May 18, 2022
@Woonters
Copy link
Contributor Author

Pull request made #17064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants