Comments (25)
Same problem here. Thanks for reporting!
from chronic.
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'
from chronic.
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.
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.
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.
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.
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.
Have these problems too running chronic with ruby-1.9.2-p0...
from chronic.
fpauser, if you look at my fork that fixes it. http://github.com/AaronH/chronic
from chronic.
I have these problems too, I have to use the AaronH fork.
from chronic.
AaronH's fork is what we are using in production, and it has been working great with ruby 1.9.2-p0.
from chronic.
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.
The AaronH-Fork is used in whenever too. Runs fine in production.
+1 for merging the AaronH fork
from chronic.
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.
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.
+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.
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.
@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.
@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.
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.
Adding myself to this Issue to get emails on any updates. Sorry for spamming you guys in the process. :-(
from chronic.
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.
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.
@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.
Fixed by @AaronH closed by 3bbfee9
from chronic.
Related Issues (20)
- Parse datetime in a full string HOT 1
- "in 1 week" vs "in a week"
- Returning an array of dates HOT 1
- Bug/Exception: NoMethodError: undefined method `begin' for nil:NilClass HOT 1
- Incorrect `last monday` HOT 1
- Parsing "next january" throws runtime error
- Common format like 'Thursday 07 March 2019' is not supporting, which is even supported by DateTime
- Chronic can't parse year "00": returns nil HOT 2
- Chronic parsing "today at noon" as tomorrow midnight - daylight saving related
- [QUESTION] Where I can find the CI service?
- incorrect parsing when introduce time HOT 3
- [Gem bug only] Parser handles missing years differently with numbers vs month names HOT 1
- what is qs in -s, --start <date:qs> HOT 1
- Chronic not selecting correct 1st monday of the month
- Chronic thinks it can parse a date if the string begins "a " HOT 2
- Returning incorrect time HOT 1
- Un-parseable date HOT 3
- Chronic doesn't take into consideration 1st date of the month when computing `nth day this month` HOT 1
- Can't set time_class to Date HOT 1
- New stable release? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chronic.