fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

[Bug]: Charting: customDateTimeFormatter and timeFormatLocale does not display the correct date for x axis (duplicate from comment)

Open Gabnight opened this issue 1 year ago • 1 comments

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 https://github.com/microsoft/fluentui/issues/31269#issuecomment-2095564110

Gabnight avatar May 06 '24 09:05 Gabnight

Misclick from comment in the original issue

Gabnight avatar May 06 '24 09:05 Gabnight