Sha256: 1b387f63b3ba842d0afd636ba369fdfedb01e46348b21ecfbb900eebdc9d3e7a
Contents?: true
Size: 806 Bytes
Versions: 18
Compression:
Stored size: 806 Bytes
Contents
# frozen_string_literal: true require 'avromatic/model/types/abstract_timestamp_type' module Avromatic module Model module Types # This subclass is used to truncate timestamp values to milliseconds. class TimestampMillisType < Avromatic::Model::Types::AbstractTimestampType def name 'timestamp-millis' end def referenced_model_classes EMPTY_ARRAY end private def truncated?(value) value.nsec % 1_000_000 == 0 end 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 end end end end
Version data entries
18 entries across 18 versions & 1 rubygems