Sha256: 41b779bebbb6978113509b1a7201218ac572ca5a92a31f515b8072e197266d21
Contents?: true
Size: 806 Bytes
Versions: 1
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 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 def referenced_model_classes EMPTY_ARRAY end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
avromatic-2.2.2 | lib/avromatic/model/types/timestamp_millis_type.rb |