Module: Avro::LogicalTypes::TimestampMillis

Defined in:
lib/avro/logical_types.rb

Class Method Summary collapse

Class Method Details

.decode(int) ⇒ Object



40
41
42
43
# File 'lib/avro/logical_types.rb', line 40

def self.decode(int)
  s, ms = int / 1000, int % 1000
  Time.at(s, ms * 1000).utc
end

.encode(value) ⇒ Object



35
36
37
38
# File 'lib/avro/logical_types.rb', line 35

def self.encode(value)
  time = value.to_time
  time.to_i * 1000 + time.usec / 1000
end