Class: Date

Inherits:
Object show all
Defined in:
lib/opendmm/utils.rb

Class Method Summary collapse

Class Method Details

.parse_with_chinese_support(str) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/opendmm/utils.rb', line 11

def parse_with_chinese_support(str)
  case str
  when /(\d{4})年(\d{1,2})月(\d{1,2})日/
    return new($1.to_i, $2.to_i, $3.to_i)
  when /(\d{2})年(\d{1,2})月(\d{1,2})日/
    year = 2000 + $1.to_i
    year -= 100 if year > Date.today.year
    return new(year, $2.to_i, $3.to_i)
  else
    return parse_without_chinese_support(str)
  end
end