Skip to content

Commit

Permalink
DST hour_of_day realign bugfix (#464)
Browse files Browse the repository at this point in the history
* fix offset bug when base_interval_validation.type is not hourly

* fix dst hour realignment bug

* update changelog with dst bugfix description

Co-authored-by: Jake Brady <[email protected]>
Co-authored-by: Jon Pascoe <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2021
1 parent 656c0c4 commit 742220c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fix for weekly interval results when requesting `occurrences_between` on a narrow range ([#487](https://github.com/seejohnrun/ice_cube/pull/487)) by [@jakebrady5](https://github.com/jakebrady5)
- When using a rule with hour_of_day validations, and asking for occurrences on the day that DST skips forward, valid occurrences would be missed. ([#464](https://github.com/seejohnrun/ice_cube/pull/464)) by [@jakebrady5](https://github.com/jakebrady5)

## [0.16.4] - 2021-10-21
### Added
Expand Down
2 changes: 1 addition & 1 deletion lib/ice_cube/validations/hour_of_day.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def realign(opening_time, start_time)
freq = base_interval_validation.interval

first_hour = Array(validations[:hour_of_day]).min_by(&:value)
time = TimeUtil::TimeWrapper.new(start_time, false)
time = TimeUtil::TimeWrapper.new(start_time, true)
if freq > 1 && base_interval_validation.type == :hour
offset = first_hour.validate(opening_time, start_time)
time.add(:hour, offset - freq)
Expand Down
9 changes: 9 additions & 0 deletions spec/examples/daily_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ module IceCube
Time.local(2013, 3, 11, 2, 0, 0) # -0700
])
end

it "should not skip days where DST changes" do
start_time = Time.local(2013, 3, 10, 0, 0, 0)
schedule = Schedule.new(start_time)
schedule.add_recurrence_rule Rule.daily.hour_of_day(19)
expect(schedule.occurrences_between(start_time, start_time + ONE_DAY)).to eq([
Time.local(2013, 3, 10, 19, 0, 0)
])
end
end

it "should update previous interval" do
Expand Down

0 comments on commit 742220c

Please sign in to comment.