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

Local Mean Time offset truncates precision #3079

Closed
ysangkok opened this issue Jan 30, 2025 · 3 comments
Closed

Local Mean Time offset truncates precision #3079

ysangkok opened this issue Jan 30, 2025 · 3 comments
Labels

Comments

@ysangkok
Copy link

It seems inconsistent that the half-minute is applied to the timestamp, but omitted from the offset:

> const zonedDateTime = Temporal.PlainDate.from({month: 1, day: 1, year: 1970}).toZonedDateTime("UTC");
> zonedDateTime.withTimeZone("Africa/Monrovia")
Temporal.ZonedDateTime {_repr_: 'Temporal.ZonedDateTime <1969-12-31T23:15:30-00:45[Africa/Monrovia]>'}

If the user supplies data that has no time of day information, I think it is reasonable for them to expect the offset + the local time to equal what they originally supplied.

The output of this calculation seems to violate that rule, since the offset omits the half minute.

@ptomato
Copy link
Collaborator

ptomato commented Jan 30, 2025

Hi! This is because the RFC 9557 string format doesn't allow HH:MM:SS in the offset part, so when we serialize a ZonedDateTime to a string, we don't want to output a string that other clients may not be able to parse. Temporal does accept the string 1969-12-31T23:15:30-00:44:30[Africa/Monrovia] and hopefully future improvements to RFC 9557 will allow outputting it as well.

The -00:45 string is still deserialized correctly when appropriate for the given time zone — see the note about MATCH-MINUTES in InterpretISODateTimeOffset.

More background reading on this:

@ysangkok
Copy link
Author

Ok, it sounds like you're already aware of this. Should I close this then?

@justingrant
Copy link
Collaborator

Yep, I'll close this issue. Thanks for the feedback!

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

No branches or pull requests

3 participants