In Files

BSON::Date

Injects behaviour for encoding date values to raw bytes as specified by the BSON spec for time.

@see bsonspec.org/#/specification

@since 2.1.0

Public Instance Methods

bson_type() click to toggle source

Get the BSON type for the date.

As the date is converted to a time, this returns the BSON type for time.

# File lib/bson/date.rb, line 42
def bson_type
  ::Time::BSON_TYPE
end
to_bson(encoded = ''.force_encoding(BINARY)) click to toggle source

Get the date as encoded BSON.

@example Get the date as encoded BSON.

Date.new(2012, 1, 1).to_bson

@return [ String ] The encoded string.

@see bsonspec.org/#/specification

@since 2.1.0

# File lib/bson/date.rb, line 35
def to_bson(encoded = ''.force_encoding(BINARY))
  ::Time.utc(year, month, day).to_bson(encoded)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.