Method: CodelessCode::Filters::Date::Matcher.parse

Defined in:
lib/codeless_code/filters/date.rb

.parse(str) ⇒ Object

param str [String] A date like 2010, 2010-12, or 2010-12-23



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/codeless_code/filters/date.rb', line 46

def self.parse(str)
  return nil unless str

  if str.size == 4
    new(::Date.parse("#{str}-01-01"), match: :year)
  elsif str.size == 7
    new(::Date.parse("#{str}-01"), match: :month)
  else
    new(::Date.parse(str), match: :day)
  end
end