Module: Avro::LogicalTypes::IntDate

Defined in:
lib/avro/logical_types.rb

Constant Summary collapse

EPOCH_START =
Date.new(1970, 1, 1)

Class Method Summary collapse

Class Method Details

.decode(int) ⇒ Object



29
30
31
# File 'lib/avro/logical_types.rb', line 29

def self.decode(int)
  EPOCH_START + int
end

.encode(date) ⇒ Object



25
26
27
# File 'lib/avro/logical_types.rb', line 25

def self.encode(date)
  (date - EPOCH_START).to_i
end