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

Respect timezone of Luxon DateTime instance when rendering an allday event #592

Closed
cimnine opened this issue Mar 29, 2024 · 3 comments
Closed

Comments

@cimnine
Copy link
Contributor

cimnine commented Mar 29, 2024

I store dates as ISO timestamps, like 2024-03-17T00:00:00.000+01:00. When I add an all day event to a calendar like in the following example, it is rendered as 20240316 in the ical format, but 20240317 would be my expectation.

const cal = new ICalCalendar();
const luxonStartDate = DateTime.fromISO('2024-03-17T00:00:00.000+01:00', { setZone: true });
const luxonEndDate = DateTime.fromISO('2024-03-18T00:00:00.000+01:00', { setZone: true });
const event = new ICalEvent({
  allDay: true,
  start: luxonStartDate,
  end: luxonEndDate,
}, cal);

const actual = event.toString();
// actual:
// DTSTART;VALUE=DATE:20240316
// DTEND;VALUE=DATE:20240317

// expected:
// DTSTART;VALUE=DATE:20240317
// DTEND;VALUE=DATE:20240318

This does not happen, when the cal object is given a fixed timezone, like cal.timezone('Europe/Zurich'). But that only works if all DateTime instances are in that same timezone – which they might not be in my case. Therefore, my instances of ICalCalendar don't have a timezone set, yet still I expect that the timezone which is embedded in the DateTime instance is respected.

I've created a PR with just some test (for now) to further explain my situation as unit tests: #591
In order to fix it, I'm unsure whether it needs to be addressed in event.ts#toString() or in tools.js#formatDate().

@sebbo2002
Copy link
Owner

Ah cool, I didn't know you could save the time zone in a DateTime object. I actually only work with UTC, maybe that's why. This is not supported yet, I always assumed that the objects were already adjusted to the local time when I get them in ical-generator. Thank you.

@sebbo2002 sebbo2002 mentioned this issue Mar 31, 2024
github-actions bot pushed a commit that referenced this issue Mar 31, 2024
# [7.1.0-develop.1](v7.0.1-develop.2...v7.1.0-develop.1) (2024-03-31)

### Bug Fixes

* Use event timezone for allDay events ([1bfeaf6](1bfeaf6))

### Features

* Apply timezone for supported allday-events ([176352c](176352c)), closes [#592](#592)
@sebbo2002
Copy link
Owner

🎉 This issue has been resolved in version 7.1.0-develop.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this issue Apr 15, 2024
# [7.1.0](v7.0.0...v7.1.0) (2024-04-15)

### Bug Fixes

* Use event timezone for allDay events ([1bfeaf6](1bfeaf6))

### Features

* Apply timezone for supported allday-events ([176352c](176352c)), closes [#592](#592)
@sebbo2002
Copy link
Owner

🎉 This issue has been resolved in version 7.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants