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

Instant#toLocaleString defaults to UTC instead of local time zone #12

Closed
stesen-wefunder opened this issue May 20, 2022 · 2 comments
Closed

Comments

@stesen-wefunder
Copy link

According to the official Temporal documentation (emphasis mine):

Because Temporal.Instant does not carry a time zone, the time zone used for the output will be the timeZone property of options, if present; and otherwise, the current time zone from the environment, which is usually the system's time zone.

However, in this implementation calling toLocaleString() on an Instant with no arguments seems to default to UTC.

It seems to be happening on this line:
https://github.com/fullcalendar/temporal/blob/ed6586020b157cf9ad647e2688dd869542c895f2/packages/temporal-polyfill/src/native/intlFactory.ts#L188

Based on my own manual testing with the Intl.DateTimeFormat API, as well as the MDN docs, simply removing the default and letting the time zone ID be undefined should provide this behavior automatically:

new Intl.DateTimeFormat(undefined, {
    year: "numeric",
    month: "numeric",
    day: "numeric",
    weekday: undefined,
    hour: "numeric",
    minute: "2-digit",
    second: "2-digit",
    timeZoneName: "long"
}).format(Date.now())
// => "5/19/2022, 6:02:01 PM Pacific Daylight Time"
@arshaw
Copy link
Member

arshaw commented Apr 22, 2023

Confirmed, this is a bug. I'll fix in the next round of code changes: https://github.com/fullcalendar/temporal#project-update-2023-04-22

@arshaw
Copy link
Member

arshaw commented Jan 7, 2024

This has been fixed in v0.2.0.

Please let me know once you confirm. Thanks!

@arshaw arshaw closed this as completed Jan 23, 2024
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

2 participants