Skip to content

#next_time breaks on DST end  #97

Description

@trafium

Issue description

According to https://www.timeanddate.com/time/change/estonia?year=2012
In Estonia, 2012 DST ended on October 28 after 03:59 (EEST) clock turned backward to 03:00 (EET).
Some evidence confirming this when working with Time class:

irb(main):030> Time.parse("2012-10-28 03:00:00 Europe/Tallinn")
=> 2012-10-28 03:00:00 +0200
irb(main):031> Time.parse("2012-10-28 02:00:00 Europe/Tallinn") + 60.minutes
=> 2012-10-28 03:00:00 +0300
irb(main):032> Time.parse("2012-10-28 02:00:00 Europe/Tallinn")
=> 2012-10-28 02:00:00 +0300
irb(main):033> Time.parse("2012-10-28 02:00:00 Europe/Tallinn") + 60.minutes
=> 2012-10-28 03:00:00 +0300
irb(main):034> Time.parse("2012-10-28 02:00:00 Europe/Tallinn") + 119.minutes
=> 2012-10-28 03:59:00 +0300
irb(main):035> Time.parse("2012-10-28 02:00:00 Europe/Tallinn") + 120.minutes
=> 2012-10-28 03:00:00 +0200
irb(main):036> Time.parse("2012-10-28 02:00:00 Europe/Tallinn").zone
=> "EEST"
irb(main):037> (Time.parse("2012-10-28 02:00:00 Europe/Tallinn") + 120.minutes).zone
=> "EET"

But Fugit::Cron breaks on an attempt to calculate next time from cron */1 * * * * starting from 03:00:00 EEST:

irb(main):044> Fugit::Cron.parse("*/1 * * * *").next_time(Time.parse("2012-10-28 02:59:00 EEST"))
=> #<EtOrbi::EoTime:0x000000010884ac98 @rday=nil, @rweek=nil, @seconds=1351382400.0, @time=nil, @zone=#<TZInfo::DataTimezone: Etc/UTC>>

irb(main):045> Fugit::Cron.parse("*/1 * * * *").next_time(Time.parse("2012-10-28 02:59:00 EEST") + 1.minute)
/Users/traf/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/et-orbi-1.2.11/lib/et-orbi/time.rb:82:in `initialize': Cannot determine timezone from "EEST" (ArgumentError)
(secs:1351382400.0,utc~:"2012-10-28 00:00:00.0",ltz~:"UTC")
(etz:nil,tnz:"EET",tziv:"2.0.6",tzidv:"1.2024.1",rv:"3.2.3",rp:"arm64-darwin23",win:false,rorv:"7.1.3.2",astz:[ActiveSupport::TimeZone, "Etc/UTC"],eov:"1.2.11",eotnz:#<TZInfo::DataTimezone: Etc/UTC>,eotnfz:"+0000",eotlzn:"Etc/UTC",eotnfZ:"UTC",
debian:nil,centos:nil,osx:"zoneinfo/Europe/Tallinn")
Try setting `ENV['TZ'] = 'Continent/City'` in your script (see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)

irb(main):046> Fugit::Cron.parse("*/1 * * * *").next_time(Time.parse("2012-10-28 03:00:00 EEST"))
/Users/traf/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/et-orbi-1.2.11/lib/et-orbi/time.rb:82:in `initialize': Cannot determine timezone from "EEST" (ArgumentError)
(secs:1351382400.0,utc~:"2012-10-28 00:00:00.0",ltz~:"UTC")
(etz:nil,tnz:"EET",tziv:"2.0.6",tzidv:"1.2024.1",rv:"3.2.3",rp:"arm64-darwin23",win:false,rorv:"7.1.3.2",astz:[ActiveSupport::TimeZone, "Etc/UTC"],eov:"1.2.11",eotnz:#<TZInfo::DataTimezone: Etc/UTC>,eotnfz:"+0000",eotlzn:"Etc/UTC",eotnfZ:"UTC",
debian:nil,centos:nil,osx:"zoneinfo/Europe/Tallinn")
Try setting `ENV['TZ'] = 'Continent/City'` in your script (see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)

irb(main):047> Fugit::Cron.parse("*/1 * * * *").next_time(Time.parse("2012-10-28 02:59:00 Europe/Tallinn") + 1.minute)
/Users/traf/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/et-orbi-1.2.11/lib/et-orbi/time.rb:82:in `initialize': Cannot determine timezone from "EEST" (ArgumentError)
(secs:1351382400.0,utc~:"2012-10-28 00:00:00.0",ltz~:"UTC")
(etz:nil,tnz:"EET",tziv:"2.0.6",tzidv:"1.2024.1",rv:"3.2.3",rp:"arm64-darwin23",win:false,rorv:"7.1.3.2",astz:[ActiveSupport::TimeZone, "Etc/UTC"],eov:"1.2.11",eotnz:#<TZInfo::DataTimezone: Etc/UTC>,eotnfz:"+0000",eotlzn:"Etc/UTC",eotnfZ:"UTC",
debian:nil,centos:nil,osx:"zoneinfo/Europe/Tallinn")
Try setting `ENV['TZ'] = 'Continent/City'` in your script (see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)

How to reproduce

The simplest piece of code that reproduces the issue:

require 'fugit'
Fugit::Cron.parse("*/1 * * * *").next_time(Time.parse("2012-10-28 03:00:00 EEST"))

Error and error backtrace (if any)

/Users/traf/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/et-orbi-1.2.11/lib/et-orbi/time.rb:82:in `initialize': Cannot determine timezone from "EEST" (ArgumentError)
(secs:1351382400.0,utc~:"2012-10-28 00:00:00.0",ltz~:"UTC")
(etz:nil,tnz:"EET",tziv:"2.0.6",tzidv:"1.2024.1",rv:"3.2.3",rp:"arm64-darwin23",win:false,rorv:"7.1.3.2",astz:[ActiveSupport::TimeZone, "Etc/UTC"],eov:"1.2.11",eotnz:#<TZInfo::DataTimezone: Etc/UTC>,eotnfz:"+0000",eotlzn:"Etc/UTC",eotnfZ:"UTC",
debian:nil,centos:nil,osx:"zoneinfo/Europe/Tallinn")
Try setting `ENV['TZ'] = 'Continent/City'` in your script (see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)

Expected behaviour

Not get error thrown

Given:

Fugit::Cron.parse("*/1 * * * *").next_time(Time.parse("2012-10-28 03:00:00 EEST")).to_t

Output: 2012-10-28 03:01:00 +0300 (+0300 signifies EEST)

Given:

Fugit::Cron.parse("*/1 * * * *").next_time(Time.parse("2012-10-28 03:59:00 EEST")).to_t

Output: 2012-10-28 03:00:00 +0200 (+0200 signifies EET)

Context

Darwin Dmitris-MacBook-Air.local 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:27 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T8103 arm64
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [arm64-darwin23]
[:env_tz, nil]
(secs:1711380674.477833,utc~:"2024-03-25 15:31:14.4778330326080322",ltz~:"EET")
(etz:nil,tnz:"EET",tziv:"2.0.6",tzidv:"1.2024.1",rv:"3.2.3",rp:"arm64-darwin23",win:false,rorv:nil,astz:nil,eov:"1.2.11",eotnz:#<TZInfo::TimezoneProxy: Africa/Cairo>,eotnfz:"+0200",eotlzn:"Africa/Cairo",eotnfZ:"EET",debian:nil,centos:nil,osx:"zoneinfo/Europe/Tallinn")
[:fugit, "1.10.1"]
[:now, 2024-03-25 17:31:15.191495 +0200, :zone, "EET"]

Activity

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

Metadata

Metadata

Assignees

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