Fixed DATE ser/deser bug.

This commit is contained in:
Jim Menard 2009-01-07 15:56:40 -05:00
parent 15055794c7
commit 17bbc83f5d
1 changed files with 4 additions and 2 deletions

View File

@ -157,7 +157,8 @@ class BSON
end end
def deserialize_date_data(buf) def deserialize_date_data(buf)
Time.at(buf.get_long) millisecs = buf.get_long()
Time.at(millisecs.to_f / 1000.0) # at() takes fractional seconds
end end
def deserialize_boolean_data(buf) def deserialize_boolean_data(buf)
@ -223,7 +224,8 @@ class BSON
def serialize_date_element(buf, key, val) def serialize_date_element(buf, key, val)
buf.put(DATE) buf.put(DATE)
self.class.serialize_cstr(buf, key) self.class.serialize_cstr(buf, key)
buf.put_long(val.to_i) millisecs = (val.to_f * 1000).to_i
buf.put_long(millisecs)
end end
def serialize_number_element(buf, key, val, type) def serialize_number_element(buf, key, val, type)