Open MeterSoft opened 6 years ago
It's fixed in my unfinished rewrite branch.
@davispuh yes, this branch works with my example but has many another issues. Example [5] pry(Order)> Chronic.parse("1/1/18") => Mon, 01 Jan 2018 12:00:00 PST -08:00 [6] pry(Order)> Chronic.parse("01/1/18") => Thu, 18 Jan 2001 12:00:00 PST -08:00 [7] pry(Order)> Chronic.parse("1/01/18") => Mon, 01 Jan 2018 12:00:00 PST -08:00 [8] pry(Order)> Chronic.parse("11/01/18") => Tue, 18 Jan 2011 12:00:00 PST -08:00
That's kinda expected behavior. There are 3 different ways how to interpret it and it just guesses it as best as it's possible.
In lib/chronic/definition.rb
you can see there is
[[ScalarYear, SeparatorSlash, ScalarMonth, SeparatorSlash, ScalarDay], :handle_sy_sm_sd],
...
[[ScalarMonth, SeparatorSlash, ScalarDay, SeparatorSlash, ScalarYear, [SeparatorDot, Scalar, :none]], :handle_sm_sd_sy],
...
[[ScalarDay, SeparatorSlash, ScalarMonth, SeparatorSlash, ScalarYear, [SeparatorDot, Scalar, :none]], :handle_sd_sm_sy],
it is possible to set default format %m%d%y ?
Default I don't think so. But you could remove other formats with monkey patching.
Anyway firstly you need to pass :endian_precedence => [:middle]
so it doesn't use dd/mm/yy
and then to remove other formats
class Chronic::DateDefinitions
def definitions
[]
end
end
class Chronic::ShortDateDefinitions
def definitions
[]
end
end
class Chronic::DateTimeDefinitions
def definitions
[]
end
end
it is possible to fix reported issue in this master branch?
It will be fixed when rewrite
branch will be finished and merged in master
.
[10] pry(#)> Chronic.parse("4/30")
=> Mon, 30 Apr 2018 12:00:00 PDT -07:00
[11] pry(#)> Chronic.parse("4/31")
=> nil
[12] pry(#)> Chronic.parse("4/32")
=> Fri, 16 Apr 2032 00:00:00 PDT -07:00
In last example should be nil