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

.getOccurences finds wrong results when crosses dst mark #213

Open
Reeywhaar opened this issue Jan 9, 2024 · 0 comments
Open

.getOccurences finds wrong results when crosses dst mark #213

Reeywhaar opened this issue Jan 9, 2024 · 0 comments

Comments

@Reeywhaar
Copy link

Library relies on minute offsets rather than timezones thus fails to get correct results when timezone offset changes midway (DST crossing)

const event = new CalendarEvent({
  //... weekly from 8 to 17 in America/New_York timezone
})

const occurences = event.occurencesBetween(
    moment('2023-10-20T00:00:00').tz('America/New_York', true),
    moment('2023-11-20T00:00:00').tz('America/New_York', true)
)

expect(occurences.map(([start, end]) => [moment(start).tz('America/New_York').format(), moment(end).tz('America/New_York').format()].join(' '))).toEqual([
  '2023-10-22T09:00:00-04:00 2023-10-22T17:00:00-04:00',
  '2023-10-29T09:00:00-04:00 2023-10-29T17:00:00-04:00',
  '2023-11-05T09:00:00-05:00 2023-11-05T17:00:00-05:00',
  '2023-11-12T09:00:00-05:00 2023-11-12T17:00:00-05:00',
  '2023-11-19T09:00:00-05:00 2023-11-19T17:00:00-05:00',
])

/*
Actual:
Array [
  "2023-10-22T09:00:00-04:00 2023-10-22T17:00:00-04:00",
  "2023-10-29T09:00:00-04:00 2023-10-29T17:00:00-04:00",
  "2023-11-05T08:00:00-05:00 2023-11-05T16:00:00-05:00",
  "2023-11-12T08:00:00-05:00 2023-11-12T16:00:00-05:00",
  "2023-11-19T08:00:00-05:00 2023-11-19T16:00:00-05:00",
]
*/
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