Module: Avro::LogicalTypes::TimestampMicros

Defined in:
lib/avro/logical_types.rb

Class Method Summary collapse

Class Method Details

.decode(int) ⇒ Object



52
53
54
55
# File 'lib/avro/logical_types.rb', line 52

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

.encode(value) ⇒ Object



47
48
49
50
# File 'lib/avro/logical_types.rb', line 47

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