Sha256: 8ccac23219180b061e3f9df06cf8c6a5476b3ae591830872cb5697e58264fb73
Contents?: true
Size: 717 Bytes
Versions: 4
Compression:
Stored size: 717 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 microseconds. class TimestampMicrosType < Avromatic::Model::Types::AbstractTimestampType def name 'timestamp-micros' end private def truncated?(value) value.nsec % 1_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) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems