Method: FeCoreExt::CoreExt::DateClassMethods#parse_reiwa
- Defined in:
- lib/fe_core_ext/core_ext/date.rb
#parse_reiwa(string) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/fe_core_ext/core_ext/date.rb', line 52 def parse_reiwa(string) string.match('令和(\S+)年(\d+)月(\d+)日') do year = 1 if ::Regexp.last_match(1) == "元" year ||= ::Regexp.last_match(1).to_i Date.new(year + 2018, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i) end end |