jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.24k stars 506 forks source link

Timezone issue #617

Open AhmedElTabarani opened 4 months ago

AhmedElTabarani commented 4 months ago

Reporting an issue

My machine's timezone is Africa/Cairo And there is daylight saving happen in Africa/Cairo in this window of dates offset was +3 in 2023-10-26 and +2 in 2023-10-27

const rule = new RRule({
  dtstart: datetime(2023, 10, 25),
  until: datetime(2023, 10, 29),
  interval: 1,
  freq: RRule.DAILY,
  tzid: 'Asia/Dubai', // i set it to Asia/Dubai (offset is +4)
  // if i set it to Africa/Cairo it will return date in UTC
  byhour: 9,
});

console.log(rule.all());

Actually:

[
  2023-10-25T08:00:00.000Z,
  2023-10-26T08:00:00.000Z,
  2023-10-27T07:00:00.000Z,
  2023-10-28T07:00:00.000Z
]

Expected:

[
  2023-10-25T05:00:00.000Z,
  2023-10-26T05:00:00.000Z,
  2023-10-27T0500:00.000Z,
  2023-10-28T05:00:00.000Z
]

I set the tzid to 'Asia/Dubai'. but it takes a weird timezone instead of the one I have given in tzid! And if i set it to Africa/Cairo it will return date in UTC

const rule = new RRule({
  dtstart: datetime(2023, 10, 25),
  until: datetime(2023, 10, 29),
  interval: 1,
  freq: RRule.DAILY,
  tzid: 'Africa/Cairo',
  byhour: 9,
});

console.log(rule.all());

Actually:

[
  2023-10-25T09:00:00.000Z,
  2023-10-26T09:00:00.000Z,
  2023-10-27T09:00:00.000Z,
  2023-10-28T09:00:00.000Z
]

Expected:

[
  2023-10-25T06:00:00.000Z,
  2023-10-26T06:00:00.000Z,
  2023-10-27T0700:00.000Z,
  2023-10-28T07:00:00.000Z
]