Skip to content

Commit 742220c

Browse files
jakebrady5jbrady1-godaddypacso
authored
DST hour_of_day realign bugfix (#464)
* 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]>
1 parent 656c0c4 commit 742220c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Fixed
1212
- 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)
13+
- 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)
1314

1415
## [0.16.4] - 2021-10-21
1516
### Added

lib/ice_cube/validations/hour_of_day.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def realign(opening_time, start_time)
2020
freq = base_interval_validation.interval
2121

2222
first_hour = Array(validations[:hour_of_day]).min_by(&:value)
23-
time = TimeUtil::TimeWrapper.new(start_time, false)
23+
time = TimeUtil::TimeWrapper.new(start_time, true)
2424
if freq > 1 && base_interval_validation.type == :hour
2525
offset = first_hour.validate(opening_time, start_time)
2626
time.add(:hour, offset - freq)

spec/examples/daily_rule_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ module IceCube
5656
Time.local(2013, 3, 11, 2, 0, 0) # -0700
5757
])
5858
end
59+
60+
it "should not skip days where DST changes" do
61+
start_time = Time.local(2013, 3, 10, 0, 0, 0)
62+
schedule = Schedule.new(start_time)
63+
schedule.add_recurrence_rule Rule.daily.hour_of_day(19)
64+
expect(schedule.occurrences_between(start_time, start_time + ONE_DAY)).to eq([
65+
Time.local(2013, 3, 10, 19, 0, 0)
66+
])
67+
end
5968
end
6069

6170
it "should update previous interval" do

0 commit comments

Comments
 (0)