Method: String#parse_date

Defined in:
lib/core_ext/string.rb

#parse_dateDate

Returns:

  • (Date)


6
7
8
9
10
11
12
13
# File 'lib/core_ext/string.rb', line 6

def parse_date
  self.scan(/(\d+)(月)(\d+)(日)/)
  month = $1.to_i
  day = $3.to_i
  today = Date.today
  year = today.month >= 10 && month == 1 ? today.year + 1 : today.year
  Date.parse("#{year}.#{month}.#{day}")
end