Module: Unidata::Extensions::Date

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

Constant Summary collapse

PICK_EPOCH =
::Date.parse('1968-01-01')

Instance Method Summary collapse

Instance Method Details

#from_unidata(value) ⇒ Object



16
17
18
# File 'lib/unidata/extensions/date.rb', line 16

def from_unidata(value)
  PICK_EPOCH + value.to_i
end

#to_unidata(value) ⇒ Object



12
13
14
# File 'lib/unidata/extensions/date.rb', line 12

def to_unidata(value)
  (value - PICK_EPOCH).to_i
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