Module: BSON::LogStashTimestamp::ClassMethods

Defined in:
lib/logstash/outputs/bson/logstash_timestamp.rb

Instance Method Summary collapse

Instance Method Details

#from_bson(bson) ⇒ ::LogStash::Timestamp

Deserialize UTC time from BSON.

Parameters:

  • bson (BSON)

    encoded time.

Returns:

  • (::LogStash::Timestamp)

    The decoded UTC time as a ::LogStash::Timestamp.

See Also:



37
38
39
40
# 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