Module: BSON::Date
- Defined in:
- lib/bson/date.rb
Overview
Injects behaviour for encoding date values to raw bytes as specified by the BSON spec for time.
Instance Method Summary collapse
-
#bson_type ⇒ Object
Get the BSON type for the date.
-
#to_bson(buffer = ByteBuffer.new) ⇒ BSON::ByteBuffer
Get the date as encoded BSON.
Instance Method Details
#bson_type ⇒ Object
Get the BSON type for the date.
As the date is converted to a time, this returns the BSON type for time.
56 57 58 |
# File 'lib/bson/date.rb', line 56 def bson_type ::Time::BSON_TYPE end |
#to_bson(buffer = ByteBuffer.new) ⇒ BSON::ByteBuffer
Get the date as encoded BSON.
49 50 51 |
# File 'lib/bson/date.rb', line 49 def to_bson(buffer = ByteBuffer.new) buffer.put_int64((jd - DATE_REFERENCE) * MILLISECONDS_IN_DAY) end |