Module: Unidata::Extensions::Date

Included in:
Date
Defined in:
lib/unidata/extensions/date.rb

Constant Summary collapse

PICK_DAY_ZERO =
::Date.parse('1967-12-31')

Instance Method Summary collapse

Instance Method Details

#from_unidata(value) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/unidata/extensions/date.rb', line 20

def from_unidata(value)
  if value == ''
    nil
  else
    PICK_DAY_ZERO + value.to_i
  end
end

#to_unidata(value) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/unidata/extensions/date.rb', line 12

def to_unidata(value)
  if value == nil
    ''
  else
    (value - PICK_DAY_ZERO).to_i
  end
end

#typecast(value) ⇒ Object



8
9
10
# File 'lib/unidata/extensions/date.rb', line 8

def typecast(value)
  value.kind_of?(::Date) ? value : value.send(:to_date)
end