Skip to content
This repository

Ruby 1.9.2 Support #11

Closed
dmarkow opened this Issue May 24, 2010 · 25 comments
Dylan Markow
dmarkow commented May 24, 2010

May not be worth looking into until Ruby 1.9.2 is actually released, but on 1.9.2-head Chronic is having some issues. Main ones I caught:

Chronic.parse("5/24/10") gives my 0010-05-24 instead of 2010-05-24

Chronic.parse("2010-05-24 09:00:00") throws an error now:

TypeError: can't convert Chronic::RepeaterTime::Tick into an exact number
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_time.rb:74:in `+'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_time.rb:74:in `block in next'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_time.rb:67:in `catch'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_time.rb:67:in `next'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_time.rb:107:in `this'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/handlers.rb:318:in `get_anchor'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/handlers.rb:90:in `day_or_time'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/handlers.rb:178:in `handle_sm_sd_sy'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/handlers.rb:193:in `handle_sy_sm_sd'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/handlers.rb:44:in `block in tokens_to_span'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/handlers.rb:40:in `each'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/handlers.rb:40:in `tokens_to_span'
    from /Users/dylan/.rvm/gems/ruby-1.9.2-head/gems/chronic-0.2.3/lib/chronic/chronic.rb:84:in `parse'
    from (irb):4
    from /Users/dylan/.rvm/rubies/ruby-1.9.2-head/bin/irb:17:in `'
Christoph Koehler

Same problem here. Thanks for reporting!

Alex Chaffee
alexch commented July 16, 2010

Also, http://isitruby19.com/chronic reports:

ruby-1.9.2-head > Chronic.parse('3 months ago saturday at 5:00 pm')
TypeError: can't iterate from Time

and I'm getting

can't iterate from Time
activesupport-2.3.8/lib/active_support/core_ext/range/include_range.rb:24:in each'
activesupport-2.3.8/lib/active_support/core_ext/range/include_range.rb:24:in
include?'
activesupport-2.3.8/lib/active_support/core_ext/range/include_range.rb:24:in include?'
activesupport-2.3.8/lib/active_support/core_ext/range/include_range.rb:24:in
include_with_range?'
chronic-0.2.3/lib/chronic/handlers.rb:350:in find_within'
chronic-0.2.3/lib/chronic/handlers.rb:326:in
get_anchor'
chronic-0.2.3/lib/chronic/handlers.rb:219:in handle_r'
chronic-0.2.3/lib/chronic/handlers.rb:224:in
handle_r_g_r'
chronic-0.2.3/lib/chronic/handlers.rb:54:in block in tokens_to_span'
chronic-0.2.3/lib/chronic/handlers.rb:50:in
each'
chronic-0.2.3/lib/chronic/handlers.rb:50:in tokens_to_span'
chronic-0.2.3/lib/chronic/chronic.rb:84:in
parse'

Francis

easy fix for the this:

@ --- orig/gems/chronic-0.3.0/lib/chronic/handlers.rb  2010-05-03 14:42:38.000000000 -0500
+++ fixed/gems/chronic-0.3.0/lib/chronic/handlers.rb    2010-07-28 11:18:24.000000000 -0500
@@ -387,6 +387,10 @@
       repeaters.sort.reverse
     end
   
+    def in_span?(span, t)
+        t && span && t >= span.begin && t 
Aaron Hurley

This fixes part of it, but the problem still remains with can't convert Chronic::RepeaterTime::Tick into an exact number

I was able to get it to work by updating the catch(:done) block in the next(pointer) function in repeater_time.rb replacing the all additions of @type with @type.time. So, that section looks like:

if pointer == :future
if @type.ambiguous?
[midnight + @type.time + offset_fix, midnight + half_day + @type.time + offset_fix, tomorrow_midnight + @type.time].each do |t|
(@current_time = t; throw :done) if t >= @now
end
else
[midnight + @type.time + offset_fix, tomorrow_midnight + @type.time].each do |t|
(@current_time = t; throw :done) if t >= @now
end
end
else # pointer == :past
if @type.ambiguous?
[midnight + half_day + @type.time + offset_fix, midnight + @type.time + offset_fix, yesterday_midnight + @type.time + half_day].each do |t|
(@current_time = t; throw :done) if t <= @now
end
else
[midnight + @type.time + offset_fix, yesterday_midnight + @type.time].each do |t|
(@current_time = t; throw :done) if t <= @now
end
end
end

Francis

Sorry - I meant to post a fix for that too, but came up with something different. Maybe your approach is better though because I ended up patching active support:

--- orig-activesupport-2.3.8/lib/active_support/core_ext/time/calculations.rb   2010-07-15 07:34:32.000000000 -0500
+++ activesupport-2.3.8/lib/active_support/core_ext/time/calculations.rb    2010-07-28 11:26:14.000000000 -0500
@@ -275,7 +275,7 @@
          if ActiveSupport::Duration === other
            other.since(self)
          else
-            plus_without_duration(other)
+            plus_without_duration(other.to_f)
          end
        end
Aaron Hurley

Yeah, I looked at doing it that way but it seemed worse.

Ideally, the to_f method on the Tick class would be called and that's all you'd have to do but it doesn't seem to work properly so calling the time element specifically seems to work.

Francis

I think your way is better. I found a similar patch in the chronic network graph of branches too. Also, I found a better patch than my in_span? patch above. I've merged than into the fork I make of your branch Aaron.

Falk Pauser

Have these problems too running chronic with ruby-1.9.2-p0...

Aaron Hurley

fpauser, if you look at my fork that fixes it. http://github.com/AaronH/chronic

Fernando Guillen

I have these problems too, I have to use the AaronH fork.

Francis

AaronH's fork is what we are using in production, and it has been working great with ruby 1.9.2-p0.

thrillcall

It would be great if AaronH's fork were merged into mainline chronic. This is causing issues that require ugly workarounds since now for example the Whenever gem is requiring aaronh-chronic as its dependency, and ultrasphinx gem requires just 'chronic' and the currently broken on 1.9.2 chronic seems to win. Had to create my own fork of aaronh-chronic, rename it in the gemspec to 'chronic' and bring both copies (of the same code!) into bundler. Please save us from the madness. ;-)

Falk Pauser

The AaronH-Fork is used in whenever too. Runs fine in production.
+1 for merging the AaronH fork

Bill Christian

Has this been integrated to the master? I am receiving the 'iterate Time' error when parsing "tomorrow at 7pm". I tried to get the AaronH fork but getting the error

Source does not contain any versions of 'chronic (>= 0, runtime)'

So I am perplexed. Using 1.9.2 Rails 3.0.3

Update:

I was able to get the AaronH fork working but would always rather work with the master branch. +1 for his fix.

Sam Goldstein

I just noticed this "Can't iterate Time" issue to when testing a project of mine (which uses Chronic) for 1.9.2 compatibility. It would be great to get this fixed in a new gem release.

Kevin Rood

+1 for merging AaronH's changes into master, or at least creating a Ruby 1.9.2 branch so that can be referenced in bundler directly like so:

gem "chronic", "0.3.9", :git => "https://github.com/mojombo/chronic.git", :branch => "ruby192"

Ved

How do I install AaronH's fork ? my following Gemfile entry fails :
gem 'chronic', '0.3.9', :git => 'git://github.com/AaronH/chronic'

fails with the following error when I do 'bundle install'

Could not find gem 'chronic (= 0.3.9, runtime)' in git://github.com/AaronH/chronic (at master).
Source does not contain any versions of 'chronic (= 0.3.9, runtime)'

Kevin Rood

@antani, without using git, you can just do this for the time being in bundler:

gem "aaronh-chronic", "0.3.9" # for ruby 1.9 compatibility

Kevin Rood

@antani, btw, you were mostly there with git, try this in bundler if you want it straight from git:

gem "aaronh-chronic", "0.3.9", :git => 'https://github.com/AaronH/chronic.git' # for ruby 1.9 compatibility

Ved

After upgrading to aarohn-chronic (via bundle install and later bundle update) I am getting follwing error:
ActionController::RoutingError (uninitialized constant CalendarsController::Chronic):
app/controllers/calendars_controller.rb:4:in <class:CalendarsController>'
app/controllers/calendars_controller.rb:1:in
'

Do I need to change my code with this change ?

Magnus Bergmark

Adding myself to this Issue to get emails on any updates. Sorry for spamming you guys in the process. :-(

Hakan Ensari

Hello folks. Likewise, just want to track updates.

Bumped into this when using Delorean, which relies on Chronic.

@mojombo: You guys must be busy. It would be great if you added a contributor or two to maintain popular projects like this.

Falk Pauser

Had problems with Delorean too. The problem is long fixed as it seems - but the fix is not getting pulled-in... this really sucks!

@Mange: Which progress?

Magnus Bergmark

@fpauser: I was commenting; everyone got an email even though I had nothing to contribute. The word was "process", not "progress". Read my post again. ;-)

Lee Jarvis
Collaborator

Fixed by @AaronH closed by 3bbfee9

Lee Jarvis leejarvis closed this May 25, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.