class Avromatic::Model::Types::TimestampMicrosType

This subclass is used to truncate timestamp values to microseconds.

Public Instance Methods

name() click to toggle source
# File lib/avromatic/model/types/timestamp_micros_type.rb, line 12
def name
  'timestamp-micros'
end
referenced_model_classes() click to toggle source
# File lib/avromatic/model/types/timestamp_micros_type.rb, line 16
def referenced_model_classes
  EMPTY_ARRAY
end

Private Instance Methods

coerce_time(input) click to toggle source
# File lib/avromatic/model/types/timestamp_micros_type.rb, line 26
def coerce_time(input)
  # value is coerced to a local Time
  # The Avro representation of a timestamp is Epoch seconds, independent
  # of time zone.
  ::Time.at(input.to_i, input.usec)
end
truncated?(value) click to toggle source
# File lib/avromatic/model/types/timestamp_micros_type.rb, line 22
def truncated?(value)
  value.nsec % 1_000 == 0
end