Module: Avro::LogicalTypes::IntDate

Defined in:
lib/avro-patches/logical_types/logical_types.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.decode(int) ⇒ Object



14
15
16
# File 'lib/avro-patches/logical_types/logical_types.rb', line 14

def self.decode(int)
  EPOCH_START + int
end

.encode(date) ⇒ Object



8
9
10
11
12
# File 'lib/avro-patches/logical_types/logical_types.rb', line 8

def self.encode(date)
  return date.to_i if date.is_a?(Numeric)

  (date - EPOCH_START).to_i
end