chronic icon indicating copy to clipboard operation
chronic copied to clipboard

Chronic parse broken

Open m4ce opened this issue 11 years ago • 5 comments

Check this out.

root@host:~ # rpm -q rubygem-chronic rubygem-chronic-0.10.2-1 root@host:~ # irb irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'chronic' => true irb(main):003:0> t = Chronic.parse("today 21:00") => Sun Oct 26 21:00:00 +0100 2014 irb(main):004:0> t = Chronic.parse("today 22:00") => Sun Oct 26 22:00:00 +0100 2014 irb(main):005:0> t = Chronic.parse("today 23:00") => Sun Oct 26 23:00:00 +0100 2014 irb(main):006:0> t = Chronic.parse("today 23:30") => nil irb(main):007:0> t = Chronic.parse("today 23:45") => nil irb(main):008:0> t = Chronic.parse("today 23:59") => nil irb(main):010:0> t = Chronic.parse("tomorrow 00:00") => Mon Oct 27 00:00:00 +0100 2014 irb(main):010:0>

Any idea?

M

m4ce avatar Oct 26 '14 08:10 m4ce

No idea, I can't reproduce, it works for me.

Chronic.parse("today 23:30")
=> 2014-10-27 23:30:00 +0200
Chronic.parse("today 23:45")
=> 2014-10-27 23:45:00 +0200
Chronic.parse("today 23:59")
=> 2014-10-27 23:59:00 +0200

davispuh avatar Oct 26 '14 23:10 davispuh

That's funny. The machine is running on CET timezone, Europe/Zurich.

irb(main):018:0> Chronic.parse('today 23:00', :now => Time.local(2014, 10, 26, 16, 00, 00)) => Sun Oct 26 23:00:00 +0100 2014 irb(main):019:0> Chronic.parse('today 23:01', :now => Time.local(2014, 10, 26, 16, 00, 00)) => nil

Funnily enough this happened only yesterday, between 23:01 and 23:59.

Also: zdump -v /usr/share/zoneinfo/Europe/Zurich | grep 2014
/usr/share/zoneinfo/Europe/Zurich Sun Oct 26 00:59:59 2014 UTC = Sun Oct 26 02:59:59 2014 CEST isdst=1 /usr/share/zoneinfo/Europe/Zurich Sun Oct 26 01:00:00 2014 UTC = Sun Oct 26 02:00:00 2014 CET isdst=0

Quite a coincidence that this issue happened on the same day when we move away from DST.

m4ce avatar Oct 27 '14 08:10 m4ce

Not a coincidence, but bug in Chronic regarding DST. Same issue as #147, #177, #179, #222, #228

I just tested it with 26th and indeed I get nil, because here also DST changes on 26th (before I tried it on 27th). Anyway I didn't investigated exactly why, but it's not really important as I've started this rewrite #278 and on that branch it works fine (you get correct 23:01). But note that DST rollover still isn't implemented even there (Chronic have never supported that yet), but it's planned to be added later. So currently if you parse something like after 1 hour and in this hour DST changes, result wont be correct.

davispuh avatar Oct 27 '14 15:10 davispuh

First of all - thanks for Chronic!

This does not work:

Chronic.parse('sunday this week').to_date

Workaround:

Chronic.parse('saturday this week').to_date.advance(days: 1)

Ruby 2.1.3

andywenk avatar Oct 30 '14 11:10 andywenk

And a week later

Chronic.parse('sunday last week')

returns nil.

McRip avatar Nov 03 '14 09:11 McRip