Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible daylight savings time issue for March 10 in AST (Rails) #179

Open
kenzie opened this issue Mar 7, 2013 · 5 comments · Fixed by cntral/chronic#1
Open

Possible daylight savings time issue for March 10 in AST (Rails) #179

kenzie opened this issue Mar 7, 2013 · 5 comments · Fixed by cntral/chronic#1
Labels

Comments

@kenzie
Copy link

kenzie commented Mar 7, 2013

When trying to parse "March 10th at 12:30pm" in Atlantic Time it's returning March 11th at 12:30am.

Time.zone = 'Atlantic Time (Canada)'
Chronic.time_class = Time.zone
Chronic.parse('March 10th at 12:30pm')
#=> Mon, 11 Mar 2013 00:30:00 ADT -03:00

Everything on March 10th, from 12pm to 12:59pm is moving ahead to March 11th from 12am to 12:59am.

Rails 3.2.12
Chronic 0.9.0 and 0.9.1

@wakiki
Copy link

wakiki commented Mar 12, 2013

+1 I have the same issue.

1.9.3p362 :021 > Time.current
=> Tue, 12 Mar 2013 11:01:30 GMT +00:00
1.9.3p362 :017 > Time.zone = "London"
=> "London"
1.9.3p362 :018 > Chronic.time_class = Time.zone
=> (GMT+00:00) London
1.9.3p362 :019 > Chronic.parse("April 1st at 9am")
=> Mon, 01 Apr 2013 09:00:00 BST +01:00
1.9.3p362 :020 > Chronic.parse("20 days from now at 9am")
=> Mon, 01 Apr 2013 10:00:00 BST +01:00

Interestingly, specifying "April 1st" works fine whereas "20 days from now" doesn't work.

Chronic 0.9.1
Rails 3.2.6

@dougc84
Copy link

dougc84 commented Mar 18, 2013

+1 same issue here. EST Time zone.

@kueda
Copy link

kueda commented Mar 23, 2016

FWIW still not fixed, but for me it only seems to happen on noon the day of the switch:

2.2.1 :001 > Chronic.parse("2016-03-13 12:29:14 PM")
 => 2016-03-14 00:29:14 -0700 
2.2.1 :002 > Chronic.parse("2016-03-14 12:29:14 PM")
 => 2016-03-14 12:29:14 -0700 
2.2.1 :003 > Chronic.parse("2016-03-12 12:29:14 PM")
 => 2016-03-12 12:29:14 -0800 
2.2.1 :005 > Chronic.parse("2016-03-13 1:29:14 PM")
 => 2016-03-13 13:29:14 -0700 
2.2.1 :006 > Chronic.parse("2016-03-13 11:29:14 PM")
 => 2016-03-13 23:29:14 -0700 

Anyone found a workaround, or a fork that works, or an alternate library?

@chuttam
Copy link

chuttam commented Mar 13, 2019

Can reproduce for March 10th, 2019 during the noon-1300 hour just as @kueda mentioned:

> Chronic.time_class
=> Time

> Chronic.time_class = Time.zone
=> #<ActiveSupport::TimeZone:0x00007f913dda7638 @name="Mountain Time (US & Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::TimezoneProxy: America/Denver>>

At this line:

range_start = Chronic.construct(@now.year, @now.month, @now.day) + @range.begin

> @now
=> Sun, 10 Mar 2019 00:00:00 MST -07:00

> @range
=> 43200..86399

> Chronic.construct(@now.year, @now.month, @now.day)
=> Sun, 10 Mar 2019 00:00:00 MST -07:00

> Chronic.construct(@now.year, @now.month, @now.day) + @range.begin
=> Sun, 10 Mar 2019 13:00:00 MDT -06:00

The addition of 12 hours to midnight (43200 seconds) doesn't account for the 1 hour gained because of the DST switch. Should really be adding "11" hours, not "12" on this day.

@chuttam
Copy link

chuttam commented Mar 28, 2019

PR with fix: #391

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants