lib/search_lingo/parsers/mdy.rb in search_lingo-2.0.0.pre1 vs lib/search_lingo/parsers/mdy.rb in search_lingo-2.0.0.pre2
- old
+ new
@@ -22,10 +22,10 @@
# defaults to today's date.
#
# Available as both a class method and an instance method.
def parse(term, relative_to: Date.today)
term.match /\A#{US_DATE}\z/ do |m|
- return Date.parse '%d/%d/%d' % m.values_at(:y, :m, :d) if m[:y]
+ return Date.parse "#{m[:y]}/#{m[:m]}/#{m[:d]}" if m[:y]
ref = relative_to
day = Integer(m[:d])
month = Integer(m[:m])
year = if month < ref.month || month == ref.month && day <= ref.day