class Avromatic::Model::Types::TimestampMillisType

This subclass is used to truncate timestamp values to milliseconds.

Public Instance Methods

name() click to toggle source
# File lib/avromatic/model/types/timestamp_millis_type.rb, line 12
def name
  'timestamp-millis'
end
referenced_model_classes() click to toggle source
# File lib/avromatic/model/types/timestamp_millis_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_millis_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 / 1000 * 1000)
end
truncated?(value) click to toggle source
# File lib/avromatic/model/types/timestamp_millis_type.rb, line 22
def truncated?(value)
  value.nsec % 1_000_000 == 0
end