Skip to content

Timezone of Recurrence Time overriding Schedule Timezone #495

Open

Description

@jtbirney

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
]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions