module Avro::LogicalTypes::TimestampNanos
Constants
- SUBUNITS_PER_SECOND
Public Class Methods
decode(int)
click to toggle source
# File lib/avro/logical_types.rb 257 def self.decode(int) 258 s, ns = int.divmod(SUBUNITS_PER_SECOND) 259 Time.at(s, ns, :nanosecond).utc 260 end
encode(value)
click to toggle source
# File lib/avro/logical_types.rb 250 def self.encode(value) 251 return value.to_i if value.is_a?(Numeric) 252 253 time = value.to_time 254 time.to_i * SUBUNITS_PER_SECOND + time.nsec 255 end