Module: BSON::Time::ClassMethods

Defined in:
lib/bson/time.rb

Overview

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#from_bson(buffer) ⇒ Time

Deserialize UTC datetime from BSON.

Parameters:

  • buffer (ByteBuffer)

    The byte buffer.

Returns:

  • (Time)

    The decoded UTC datetime.

See Also:

Since:

  • 2.0.0


55
56
57
58
# 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