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

possible issue, skipping initial date when tzid and dtstart is provided #625

Open
3 tasks done
itai-sagi opened this issue May 26, 2024 · 0 comments
Open
3 tasks done

Comments

@itai-sagi
Copy link

itai-sagi commented May 26, 2024

Reporting an issue

Hi,
I have tried switching from UTC based RRule interval generation to a timezone based as it handles some edge cases, however, while doing the move, I noticed that the first time interval is different.

import {Frequency, RRule, Options} from "rrule";

process.env.TZ = 'UTC';

const toDate = `2024-05-14 06:59:59.999+00`; // corresponds with end-of-day in America/Los_Angeles timezone

const frequencyRuleWithTz: Options = {
    tzid: 'America/Los_Angeles',
    byhour: 5,
    count: 1,
    dtstart: new Date(toDate),
    freq: Frequency.DAILY,
} as any;

const frequencyRuleOld: Options = {
    tzid: 'UTC',
    byhour: 12,
    count: 1,
    dtstart: new Date(toDate),
    freq: Frequency.DAILY,
} as any;

let rrule = new RRule(frequencyRuleWithTz as any);

for (const date of rrule.all()) {
    console.log("America/Los_Angeles");
    console.log(date.toISOString());
}

rrule = new RRule(frequencyRuleOld as any);

for (const date of rrule.all()) {
    console.log("UTC");
    console.log(date.toISOString());
}

Output:

America/Los_Angeles
2024-05-15T12:00:00.999Z

UTC
2024-05-14T12:00:00.999Z

the reason why I expected it would be a seemless migration is because UTC 12 PM <=> LA 5 AM (excluding daylight savings), but instead, the 1st iteration is a day after.

this is the value I expected while providing frequencyRuleWithTz

2024-05-14T12:00:00.999Z

I am not sure if that's the expected behavior, but on this case - it does seem like a bug.

  • The version of rrule you are using [2.8.1, also reproduced using 2.7.0]
  • Your operating system [ macOS ]
  • Your local timezone (run $ date from the command line
    of the machine showing the bug) [ node process is UTC ]
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

1 participant