Sha256: e69b1f7cf4a74b427ad010543a10e36e1d4164116dd63e077b86a952c60ba3b2

Contents?: true

Size: 633 Bytes

Versions: 43

Compression:

Stored size: 633 Bytes

Contents

require 'avromatic/model/attribute/abstract_timestamp'

module Avromatic
  module Model
    module Attribute

      # This subclass is used to truncate timestamp values to milliseconds.
      class TimestampMillis < AbstractTimestamp

        def value_coerced?(value)
          value.is_a?(Time) && value.usec % 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 / 1000 * 1000)
        end

      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
avromatic-1.0.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.33.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.32.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.32.0.rc0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.31.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.30.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.29.1 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.29.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.28.1 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.27.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.26.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.25.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.24.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.23.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.22.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.21.1 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.21.0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.21.0.rc1 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.21.0.rc0 lib/avromatic/model/attribute/timestamp_millis.rb
avromatic-0.20.0 lib/avromatic/model/attribute/timestamp_millis.rb