Skip to content

Commit

Permalink
Ensure leaving ZH DST is OK, gh-53
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Mar 25, 2021
1 parent f3271c4 commit 550e571
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## fugit 1.4.4 not yet released

* Ensure leaving ZH DST is OK, gh-53


## fugit 1.4.3 released 2021-03-23

Expand Down
3 changes: 2 additions & 1 deletion lib/fugit/cron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def inc_month

def inc_day
inc((24 - @t.hour) * 3600 - @t.min * 60 - @t.sec)
inc( - @t.hour * 3600) if @t.hour != 0 # compensate for entering DST
#inc( - @t.hour * 3600) if @t.hour != 0 # compensate for entering DST
inc( - @t.hour * 3600) if @t.hour > 0 && @t.hour < 7
end
def inc_hour
inc((60 - @t.min) * 60 - @t.sec)
Expand Down
24 changes: 24 additions & 0 deletions spec/cron_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,30 @@
end
end

it 'correctly increments out of DST (gh-53 e)' do

in_zone 'Europe/Zurich' do

#c = Fugit::Nat.parse('every monday at midnight')
c = Fugit::Cron.parse('0 0 * * 2')
t = EtOrbi::EoTime.parse('2021-10-18 12:00:00')

points =
4.times.collect do
t = c.next_time(t)
tu = t.dup.utc
"#{t.strftime('%F_%H:%M_%Z')}__#{tu.strftime('%F_%H:%M_%Z')}"
end

expect(points.join("\n")).to eq(%w[
2021-10-19_00:00_CEST__2021-10-18_22:00_UTC
2021-10-26_00:00_CEST__2021-10-25_22:00_UTC
2021-11-02_00:00_CET__2021-11-01_23:00_UTC
2021-11-09_00:00_CET__2021-11-08_23:00_UTC
].join("\n"))
end
end

it 'correctly increments out of DST' do

in_zone 'America/Los_Angeles' do
Expand Down

0 comments on commit 550e571

Please sign in to comment.