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, **options) ⇒ Time

Deserialize UTC datetime from BSON.

Parameters:

  • buffer (ByteBuffer)

    The byte buffer.

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :mode (nil | :bson)

    Decoding mode to use.

Returns:

  • (Time)

    The decoded UTC datetime.

See Also:

Since:

  • 2.0.0



116
117
118
119
# File 'lib/bson/time.rb', line 116

def from_bson(buffer, **options)
  seconds, fragment = Int64.from_bson(buffer, mode: nil).divmod(1000)
  at(seconds, fragment * 1000).utc
end