You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This line [1] suggest that one could use Date as the time_class. But if you do, then this other line fails[2] because the class Date doesn't have the now method.
You would think that the option :now would work, but line[3] fails as it doesn't use this option.
require 'date'
require 'chronic'
Chronic.time_class = Date
Chronic.parse('2000 January 1st', now: Time.now)
Error:
Traceback (most recent call last):
11: from bin/console:14:in `<main>'
10: from (irb):5
9: from /home/monkey/.rvm/gems/ruby-2.7.2/gems/chronic-0.10.2/lib/chronic.rb:90:in `parse'
8: from /home/monkey/.rvm/gems/ruby-2.7.2/gems/chronic-0.10.2/lib/chronic/parser.rb:60:in `parse'
7: from /home/monkey/.rvm/gems/ruby-2.7.2/gems/chronic-0.10.2/lib/chronic/parser.rb:228:in `tokenize'
6: from /home/monkey/.rvm/gems/ruby-2.7.2/gems/chronic-0.10.2/lib/chronic/parser.rb:228:in `each'
5: from /home/monkey/.rvm/gems/ruby-2.7.2/gems/chronic-0.10.2/lib/chronic/parser.rb:229:in `block in tokenize'
4: from /home/monkey/.rvm/gems/ruby-2.7.2/gems/chronic-0.10.2/lib/chronic/ordinal.rb:12:in `scan'
3: from /home/monkey/.rvm/gems/ruby-2.7.2/gems/chronic-0.10.2/lib/chronic/ordinal.rb:12:in `each_index'
2: from /home/monkey/.rvm/gems/ruby-2.7.2/gems/chronic-0.10.2/lib/chronic/ordinal.rb:19:in `block in scan'
1: from /home/monkey/.rvm/gems/ruby-2.7.2/gems/chronic-0.10.2/lib/chronic/date.rb:66:in `make_year'
NoMethodError (undefined method `now' for Date:Class)
Did you mean? new
Chronic gem basically parse the given string to suitable Time or DateTime object, when it comes to Date, we cannot handle the time based methods (i.e: we cannot find hour, mins and seconds). I think thats why they don't provide option to handle Date class.
This line [1] suggest that one could use
Date
as thetime_class
. But if you do, then this other line fails[2] because the classDate
doesn't have thenow
method.You would think that the option
:now
would work, but line[3] fails as it doesn't use this option.Error:
[1] https://github.com/mojombo/chronic/blob/master/lib/chronic.rb#L145
[2] https://github.com/mojombo/chronic/blob/master/lib/chronic/parser.rb#L60
[3] https://github.com/mojombo/chronic/blob/master/lib/chronic/date.rb#L65
The text was updated successfully, but these errors were encountered: