module BSON::TimeWithZone
Injects behaviour for encoding ActiveSupport::TimeWithZone values to raw bytes as specified by the BSON
spec for time.
@see bsonspec.org/#/specification
@since 4.4.0
Public Instance Methods
_bson_to_i()
click to toggle source
@api private
# File lib/bson/time_with_zone.rb, line 52 def _bson_to_i # Workaround for JRuby's #to_i rounding negative timestamps up # rather than down (https://github.com/jruby/jruby/issues/6104) if BSON::Environment.jruby? (self - usec.to_r/1000000).to_i else to_i end end
bson_type()
click to toggle source
to_bson(buffer = ByteBuffer.new)
click to toggle source
Get the ActiveSupport::TimeWithZone as encoded BSON
.
@example Get the ActiveSupport::TimeWithZone as encoded BSON
.
Time.utc(2012, 12, 12, 0, 0, 0).in_time_zone("Pacific Time (US & Canada)").to_bson
@return [ BSON::ByteBuffer
] The buffer with the encoded object.
@see bsonspec.org/#/specification
@since 4.4.0
# File lib/bson/time_with_zone.rb, line 39 def to_bson(buffer = ByteBuffer.new) buffer.put_int64((to_i * 1000) + (usec / 1000)) end