module BSON::Time::ClassMethods

Public Instance Methods

from_bson(buffer) click to toggle source

Deserialize UTC datetime from BSON.

@param [ ByteBuffer ] buffer The byte buffer.

@return [ Time ] The decoded UTC datetime.

@see bsonspec.org/#/specification

@since 2.0.0

# File lib/bson/time.rb, line 55
def from_bson(buffer)
  seconds, fragment = Int64.from_bson(buffer).divmod(1000)
  at(seconds, fragment * 1000).utc
end