Fix dates to return as UTC.
Signed-off-by: Mike Dirolf <mike@dirolf.com>
This commit is contained in:
parent
dbd656580d
commit
91b1b0ad8f
|
@ -245,7 +245,7 @@ class BSON
|
|||
|
||||
def deserialize_date_data(buf)
|
||||
millisecs = buf.get_long()
|
||||
Time.at(millisecs.to_f / 1000.0) # at() takes fractional seconds
|
||||
Time.at(millisecs.to_f / 1000.0).utc
|
||||
end
|
||||
|
||||
def deserialize_boolean_data(buf)
|
||||
|
|
|
@ -58,7 +58,7 @@ class XMLToRuby
|
|||
when 'array'
|
||||
array_to_ruby(e.elements)
|
||||
when 'date'
|
||||
Time.at(e.text.to_f / 1000.0)
|
||||
Time.at(e.text.to_f / 1000.0).utc
|
||||
when 'regex'
|
||||
regex_to_ruby(e.elements)
|
||||
when 'null'
|
||||
|
|
|
@ -117,6 +117,13 @@ class BSONTest < Test::Unit::TestCase
|
|||
assert_in_delta doc['date'], doc2['date'], 0.001
|
||||
end
|
||||
|
||||
def test_date_returns_as_utc
|
||||
doc = {'date' => Time.now}
|
||||
@b.serialize(doc)
|
||||
doc2 = @b.deserialize
|
||||
assert_equal "UTC", doc2['date'].zone
|
||||
end
|
||||
|
||||
def test_dbref
|
||||
oid = ObjectID.new
|
||||
doc = {}
|
||||
|
|
Loading…
Reference in New Issue