Class: Qif::DateFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/qif/date_format.rb

Constant Summary collapse

SUPPORTED_DATEFORMAT =
{
  "dd/mm/yyyy"  => "%d/%m/%Y",
  "d/mm/yyyy"   => "%d/%m/%Y",
  "dd/m/yyyy"   => "%d/%m/%Y",
  "d/m/yyyy"    => "%d/%m/%Y",

  "dd/mm/yy"    => "%d/%m/%y",
  "d/mm/yy"     => "%d/%m/%y",
  "dd/m/yy"     => "%d/%m/%y",
  "d/m/yy"      => "%d/%m/%y",

  "mm/dd/yyyy"  => "%m/%d/%Y",
  "m/dd/yyyy"   => "%m/%d/%Y",
  "mm/d/yyyy"   => "%m/%d/%Y",
  "m/d/yyyy"    => "%m/%d/%Y",

  "mm/dd/yy"    => "%m/%d/%y",
  "m/dd/yy"     => "%m/%d/%y",
  "mm/d/yy"     => "%m/%d/%y",
  "m/d/yy"      => "%m/%d/%y",
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format = 'dd/mm/yyyy') ⇒ DateFormat


29
30
31
# File 'lib/qif/date_format.rb', line 29

def initialize(format = 'dd/mm/yyyy')
  @format = format
end

Instance Attribute Details

#format(date) ⇒ Object (readonly)

Returns the value of attribute format


5
6
7
# File 'lib/qif/date_format.rb', line 5

def format
  @format
end

Instance Method Details

#parse(date) ⇒ Object


33
34
35
# File 'lib/qif/date_format.rb', line 33

def parse(date)
  Date.strptime(date, convert_format_to_strftime)
end