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

WIP: Cookbook example showing how to handle icalendar time zones #2894

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Jun 11, 2024

This is an example of how a ZonedDateTime object with a custom time zone could work, if TimeZone objects are removed. (#2853)

This shows integration with ical.js. It's a ZonedDateTime-wrapper object that internally maintains a real Temporal.ZonedDateTime object, but it takes an ICAL.Timezone instead of a Temporal.TimeZone. If the ICAL.Timezone object has the ID of an IANA time zone, we delegate everything to the real Temporal.ZonedDateTime and use the host's time zone database. If the ID is not an IANA ID, we fall back to the ICAL.Timezone's VTIMEZONE data.

Draft; still needs test data with which to make sure everything works, and a cookbook page.

TODO: Add test data & make sure it works
TODO: Comment code better & add page in cookbook
Copy link
Collaborator

@justingrant justingrant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this, seems like a reasonable starting point.

}
// this.#impl with a non-IANA time zone uses UTC internally, so we can just
// calculate the plain date-time in UTC and add the UTC offset.
return this.#impl.toPlainDateTime().add({ nanoseconds: this.offsetNanoseconds });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this break around DST transitions that PDT is unaware of? That may be OK for a cookbook sample, but it may deserve a comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it'll break. this.#impl.toPlainDateTime() will be unaware of any DST transitions at all, but adding this.offsetNanoseconds will correctly account for DST transitions in the VTIMEZONE.

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

Successfully merging this pull request may close these issues.

None yet

2 participants