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]: Charting: customDateTimeFormatter and timeFormatLocale does not display the correct date for x axis (duplicate from comment) #31275

Closed
Gabnight opened this issue May 6, 2024 · 1 comment

Comments

@Gabnight
Copy link

Gabnight commented May 6, 2024

Hello @AtishayMsft

Creating new date object without the "Z" at the end is a valid way to create date from local time zone:
Here is an exemple from the doc you mention:

Local time
All other formats (including the above date-time form of the ISO format when the time zone offset is absent) are interpreted as local time. Notice how the components in the input string don't completely match those in the output ISO string.
console.log(new Date('2010-10-10T02:10').toISOString())
// Output (IST): "2010-10-09T20:40:00.000Z"
// Output (PDT): "2010-10-10T09:10:00.000Z"

From MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#date_time_string_format):

Various components can be omitted, so the following are all valid:
Date-only form: YYYY, YYYY-MM, YYYY-MM-DD
Date-time form: one of the above date-only forms, followed by T, followed by HH:mm, HH:mm:ss, or HH:mm:ss.sss. Each combination can be followed by a time zone offset.
For example, "2011-10-10" (date-only form), "2011-10-10T14:48:00" (date-time form), or "2011-10-10T14:48:00.000+09:00" (date-time form with milliseconds and time zone) are all valid date time strings.

If you prefer, new Date("2020-03-05T00:00:00.000") is equal to new Date(2020, 2, 5).
image

Moreover, as i explain in the bug, you can repro this issue in the react-charting demo website in the section "LineChart custom date axis locale" when you access the website in a local time zone different from UTC:
https://developer.microsoft.com/en-us/fluentui#/controls/web/linechart
image

For those reason, I'm reopening the issue.
Feel free to ask me more info if you need to.

Originally posted by @Gabnight in #31269 (comment)

@Gabnight Gabnight changed the title Hello @AtishayMsft [Bug]: Charting: customDateTimeFormatter and timeFormatLocale does not display the correct date for x axis (duplicate from comment) May 6, 2024
@Gabnight
Copy link
Author

Gabnight commented May 6, 2024

Misclick from comment in the original issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant