Module: BSON::Time::ClassMethods

Defined in:
lib/bson/time.rb

Overview

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#from_bson(bson) ⇒ Time

Deserialize UTC datetime from BSON.

Parameters:

  • bson (BSON)

    The bson representing UTC datetime.

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(bson)
  seconds, fragment = Int64.from_bson(bson).divmod(1000)
  at(seconds, fragment * 1000).utc
end