Closed zhon closed 12 years ago
The first one has never worked, the second one works fine for me. What version of Chronic are you using?
>> Chronic::VERSION
=> "0.6.4"
>> Chronic.parse '29th of November'
=> 2011-11-29 12:00:00 -0800
Chronic Version 0.6.4 on Windows Ruby 1.9.2 gem says 0.6.4 Chronic::VERSION says 0.3.9
I am also having issues with this. Same result as zhon on the same versions. However, I just posted another issue that is slightly different, but I think it has something to do with it. see https://github.com/mojombo/chronic/issues/73 Something is strange about this November....
On the current branch
Chronic.parse '29th of November' # works
Chronic.parse '29th day of November' # -> nil
@zhon the latter shouldn't have a handler anyway. When you say 'on the current branch' do you mean it works on HEAD but not the latest version of Chronic?
Yes it works on HEAD (I just check it out and checked) but not when I did
gem install chronic
gem list chronic
*** LOCAL GEMS ***
chronic (0.6.4)
irb(main):001:0> require 'chronic'
=> true
irb(main):002:0> Chronic::VERSION
=> "0.3.9"
irb(main):003:0>
Weird, that shouldn't be the case as I tested it on both. I'll be pushing a new version later this week anyway so if this is fixed to you on HEAD you'll see these changes on the next stable release. Thanks for reporting
@zhon the latter shouldn't have a handler anyway.
I was hoping Chronic could help me parsing time and date legalizes. For example,
"on Tuesday, the 29th day of November, 2011, ...legal jargon about money and address of courthouse steps.., at 10:30 a.m."
seems perfectly reasonable to a lawyer.
I have been banging my head on this one for a while. If Chronic can help, I would be eternally grateful.
Thank you,
Zhon
zhon, Chronic ignores any word which doesn't interest its tokenizer. It builds a pattern and executes a method which is mapped to said pattern. Meaning what you're looking for is probably perfectly doable. For example:
>> Chronic.parse 'the 29th of november, 2011, some stuff here etc at 10:30am'
=> 2011-11-29 10:30:00 -0800
But, altering this string by adding a single word that Chronics tokenizer is interested in, could break if there's no associated handler for this pattern:
>> Chronic.parse 'Tuesday the 29th of november, 2011, some stuff here etc at 10:30am'
=> nil
It's all about having a handler available to match specific patterns. If you have a certain pattern you'd like to match, please feel free to open an issue with the debug information returned by running these commands:
>> Chronic.debug = true
>> Chronic.parse("my string here")
debug output here
Example:
Chronic.parse 'this string contains something chronic is interested in: 10pm'
[ this(grabber-this) , interested(timezone) , in:(pointer-future) , 10(repeater-time-36000?) , pm(repeater-dayportion-pm) ]
So this tells us building a Handler which responds to [:grabber, :timezone, :pointer, :repeater_time, :repeater_day_portion]
means we can parse these values and return some quality information.
Hope that helped
Chronic.parse 'the 29th' -> nil Chronic.parse '29th of November' -> nil