minor: c ext return dates as UTC, update credits, tweak last commit

This commit is contained in:
Mike Dirolf 2009-07-16 16:32:57 -04:00
parent 91b1b0ad8f
commit 6cd976398e
5 changed files with 7 additions and 3 deletions

View File

@ -290,6 +290,9 @@ John Nunemaker, http://railstips.org
* Collection#create_index takes symbols as well as strings
* Fix for Collection#save
David James, djames@sunlightfoundation.com
* Fix dates to return as UTC
= License
Copyright 2008-2009 10gen Inc.

View File

@ -541,6 +541,7 @@ static VALUE get_value(const char* buffer, int* position, int type) {
VALUE microseconds = INT2NUM((millis % 1000) * 1000);
value = rb_funcall(Time, rb_intern("at"), 2, seconds, microseconds);
value = rb_funcall(value, rb_intern("utc"), 0)
*position += 8;
break;
}

View File

@ -245,7 +245,7 @@ class BSON
def deserialize_date_data(buf)
millisecs = buf.get_long()
Time.at(millisecs.to_f / 1000.0).utc
Time.at(millisecs.to_f / 1000.0).utc # at() takes fractional seconds
end
def deserialize_boolean_data(buf)

View File

@ -58,7 +58,7 @@ class XMLToRuby
when 'array'
array_to_ruby(e.elements)
when 'date'
Time.at(e.text.to_f / 1000.0).utc
Time.at(e.text.to_f / 1000.0)
when 'regex'
regex_to_ruby(e.elements)
when 'null'

View File

@ -121,7 +121,7 @@ class BSONTest < Test::Unit::TestCase
doc = {'date' => Time.now}
@b.serialize(doc)
doc2 = @b.deserialize
assert_equal "UTC", doc2['date'].zone
assert doc2['date'].utc?
end
def test_dbref