Sha256: 329a0acc57e98dc2baf9c498f66cd1bcb9f2ee8a7d758d81b9621833f9d07743

Contents?: true

Size: 619 Bytes

Versions: 43

Compression:

Stored size: 619 Bytes

Contents

require 'avromatic/model/attribute/abstract_timestamp'

module Avromatic
  module Model
    module Attribute

      # This subclass is used to truncate timestamp values to microseconds.
      class TimestampMicros < AbstractTimestamp

        def value_coerced?(value)
          value.is_a?(Time) && value.nsec % 1000 == 0
        end

        private

        def coerce_time(value)
          # value is coerced to a local Time
          # The Avro representation of a timestamp is Epoch seconds, independent
          # of time zone.
          Time.at(value.to_i, value.usec)
        end

      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
avromatic-0.19.0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.18.1 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.18.0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.18.0.rc0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.17.1 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.17.0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.15.1 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.15.0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.15.0.rc0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.14.0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.14.0.rc1 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.14.0.rc0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.13.0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.13.0.rc1 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.13.0.rc0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.12.0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.11.2 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.11.1 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.11.0 lib/avromatic/model/attribute/timestamp_micros.rb
avromatic-0.10.0 lib/avromatic/model/attribute/timestamp_micros.rb