Module: EPUBInfo::Utils

Defined in:
lib/epubinfo/utils.rb

Class Method Summary collapse

Class Method Details

.parse_iso_8601_date(date_str) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/epubinfo/utils.rb', line 3

def self.parse_iso_8601_date(date_str)
  case date_str.count('-')
  when 0
    Date.strptime(date_str, '%Y')
  when 1
    Date.strptime(date_str, '%Y-%m')
  when 2
    Date.strptime(date_str, '%Y-%m-%d')
  end
end