Skip to content

Incorrect offset applied to hour of day #451

@jakebrady5

Description

@jakebrady5

In this situation, schedule.occurrences_between(start_time, end_time) will return the correct occurrence, but adding spans: true will yield no results. I have opened a PR with a fix, but could use assistance is assessing whether this fix is appropriate.

Schedule:

=> #<IceCube::Schedule:0x007f8e2abc8558
 @all_exception_rules=[],
 @all_recurrence_rules=
  [#<IceCube::WeeklyRule:0x007f8e2abeb6e8
    @interval=2,
    @start_time=2018-08-11 18:00:00 UTC,
    @time=2018-08-12 10:00:00 UTC,
    @uses=0,
    @validations=
     {:interval=>
       [#<IceCube::Validations::WeeklyInterval::Validation:0x007f8e2abea1a8
         @interval=2,
         @week_start=:sunday>],
      :day=>[#<IceCube::Validations::Day::Validation:0x007f8e2ac1c680 @day=6>],
      :hour_of_day=>[#<IceCube::Validations::HourOfDay::Validation:0x007f8e2ac07dc0 @hour=10>],
      :minute_of_hour=>
       [#<IceCube::Validations::MinuteOfHour::Validation:0x007f8e2ac07708 @minute=0>],
      :second_of_minute=>
       [#<IceCube::Validations::SecondOfMinute::Validation:0x007f8e2ac070a0 @second=0>]},
    @week_start=:sunday>],
 @end_time=2018-08-07 15:00:00 UTC,
 @start_time=2018-08-07 07:00:00 UTC>
start_time = Time.utc(2018, 8, 11, 7, 0, 0)
end_time = Time.utc(2018, 8, 12, 6, 59, 59)
[16] pry(main)> schedule.occurrences_between(start_time, end_time)
=> [2018-08-11 10:00:00 UTC]
[17] pry(main)> schedule.occurrences_between(start_time, end_time, spans: true)
=> []

In debugging, I found that this line was causing time to be moved beyond the expected occurrence result. Additionally freq in this context was 2 from the biweekly rule.

The PR has a spec to cover this situation, but again I am not convinced that my approach is best.

Any assistance is appreciated!

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