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

Chronic parse broken #282

Open
m4ce opened this issue Oct 26, 2014 · 5 comments
Open

Chronic parse broken #282

m4ce opened this issue Oct 26, 2014 · 5 comments
Labels

Comments

@m4ce
Copy link

m4ce commented Oct 26, 2014

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

@davispuh
Copy link
Collaborator

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

@m4ce
Copy link
Author

m4ce commented Oct 27, 2014

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.

@davispuh
Copy link
Collaborator

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 davispuh added the bug label Oct 27, 2014
@andywenk
Copy link

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

@McRip
Copy link

McRip commented Nov 3, 2014

And a week later

Chronic.parse('sunday last week')

returns nil.

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

No branches or pull requests

4 participants