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

Timezone of Recurrence Time overriding Schedule Timezone #495

Open
jtbirney opened this issue Mar 30, 2021 · 0 comments
Open

Timezone of Recurrence Time overriding Schedule Timezone #495

jtbirney opened this issue Mar 30, 2021 · 0 comments

Comments

@jtbirney
Copy link

I came across some strange behavior when adding recurrence times. I did discover that the issue can be resolved by converting everything to the same timezone before adding recurrence times, but the actual behavior is not intuitive and I believe should be fixed.

Description: If a recurrence time is added in a different timezone than the start time of the schedule, the timezone of the recurrence time interferes with other rules.

To Reproduce:

timezone = "America/New_York"
start_at = Time.use_zone(timezone) { Time.parse("March 15 , 2021 11:00AM") }.in_time_zone(timezone)
end_at = start_at + 45.minutes
schedule = IceCube::Schedule.new(start_at, end_time: end_at)
rule = IceCube::Rule.monthly.day_of_week(start_at.wday => [1, 3])
schedule.add_recurrence_rule(rule)
schedule.occurrences_between(start_at, start_at + 3.months)

rtime = Time.parse("2021-03-29T10:00:00.000Z").in_time_zone("America/Los_Angeles")
schedule.add_recurrence_time rtime

schedule.occurrences_between(start_at, start_at + 3.months)

Expected Output:

[
  Mon, 15 Mar 2021 11:00:00 EDT -04:00,
  Mon, 29 Mar 2021 03:00:00 PDT -07:00,
  Mon, 05 Apr 2021 11:00:00 EDT -04:00,
  Mon, 19 Apr 2021 11:00:00 EDT -04:00,
  Mon, 03 May 2021 11:00:00 EDT -04:00,
  Mon, 17 May 2021 11:00:00 EDT -04:00,
  Mon, 07 Jun 2021 11:00:00 EDT -04:00
]

Actual Output:

[
  Mon, 15 Mar 2021 11:00:00 EDT -04:00,
  Mon, 29 Mar 2021 03:00:00 PDT -07:00,
  Mon, 05 Apr 2021 11:00:00 PDT -07:00,
  Mon, 19 Apr 2021 11:00:00 PDT -07:00,
  Mon, 03 May 2021 11:00:00 PDT -07:00,
  Mon, 17 May 2021 11:00:00 PDT -07:00,
  Mon, 07 Jun 2021 11:00:00 PDT -07: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