Giter VIP home page Giter VIP logo

Comments (25)

ckoehler avatar ckoehler commented on July 3, 2024

Same problem here. Thanks for reporting!

from chronic.

alexch avatar alexch commented on July 3, 2024

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:ininclude?'
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:ininclude_with_range?'
chronic-0.2.3/lib/chronic/handlers.rb:350:in find_within' chronic-0.2.3/lib/chronic/handlers.rb:326:inget_anchor'
chronic-0.2.3/lib/chronic/handlers.rb:219:in handle_r' chronic-0.2.3/lib/chronic/handlers.rb:224:inhandle_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:ineach'
chronic-0.2.3/lib/chronic/handlers.rb:50:in tokens_to_span' chronic-0.2.3/lib/chronic/chronic.rb:84:inparse'

from chronic.

francis avatar francis commented on July 3, 2024

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 <= span.end
+    end
+
     # Recursively finds repeaters within other repeaters.
     # Returns a Span representing the innermost time span
     # or nil if no repeater union could be found
@@ -397,8 +401,7 @@
       head, *rest = tags
       head.start = pointer == :future ? span.begin : span.end
       h = head.this(:none)
-            
-      if span.include?(h.begin) || span.include?(h.end)
+      if in_span?(span, h.begin) || in_span?(span, h.end)
         return find_within(rest, h, pointer)
       else
         return nil

from chronic.

AaronH avatar AaronH commented on July 3, 2024

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

from chronic.

francis avatar francis commented on July 3, 2024

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

from chronic.

AaronH avatar AaronH commented on July 3, 2024

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.

from chronic.

francis avatar francis commented on July 3, 2024

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.

from chronic.

fpauser avatar fpauser commented on July 3, 2024

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

from chronic.

AaronH avatar AaronH commented on July 3, 2024

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

from chronic.

fguillen avatar fguillen commented on July 3, 2024

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

from chronic.

francis avatar francis commented on July 3, 2024

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

from chronic.

thrillcall avatar thrillcall commented on July 3, 2024

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. ;-)

from chronic.

fpauser avatar fpauser commented on July 3, 2024

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

from chronic.

billc avatar billc commented on July 3, 2024

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.

from chronic.

samg avatar samg commented on July 3, 2024

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.

from chronic.

kevinrood avatar kevinrood commented on July 3, 2024

+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"

from chronic.

antani avatar antani commented on July 3, 2024

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)'

from chronic.

kevinrood avatar kevinrood commented on July 3, 2024

@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

from chronic.

kevinrood avatar kevinrood commented on July 3, 2024

@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

from chronic.

antani avatar antani commented on July 3, 2024

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<top (required)>'

Do I need to change my code with this change ?

from chronic.

Mange avatar Mange commented on July 3, 2024

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

from chronic.

hakanensari avatar hakanensari commented on July 3, 2024

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.

from chronic.

fpauser avatar fpauser commented on July 3, 2024

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?

from chronic.

Mange avatar Mange commented on July 3, 2024

@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. ;-)

from chronic.

leejarvis avatar leejarvis commented on July 3, 2024

Fixed by @AaronH closed by 3bbfee9

from chronic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.