module BSON::LogStashTimestamp::ClassMethods

Public Instance Methods

from_bson(bson) click to toggle source

Deserialize UTC time from BSON. @param [ BSON ] bson encoded time. @return [ ::LogStash::Timestamp ] The decoded UTC time as a ::LogStash::Timestamp. @see bsonspec.org/#/specification

# File lib/logstash/outputs/bson/logstash_timestamp.rb, line 37
def from_bson(bson)
  seconds, fragment = BSON::Int64.from_bson(bson).divmod(1000)
  new(::Time.at(seconds, fragment * 1000).utc)
end