Code:
import bson
from datetime import datetime
my_date = datetime(1965, 1, 1, 15, 48, 57, 500340)
my_dict =
my_bson = bson.BSON.encode(my_dict)
print my_bson.decode(tz_aware=False)
print my_bson.decode(tz_aware=True)
Output:
{u'my_date': datetime.datetime(1965, 1, 1, 15, 48, 58, 16277216)}-
- Notice that the above datetime is not even valid as the microseconds field is far too large
- Also: the call does not fail on tz_aware=False, however it does on tz_aware=True as shown below.
Traceback (most recent call last):
File "bsonbug.py", line 10, in <module>
print my_bson.decode(tz_aware=True)
File "/usr/local/lib/python2.6/dist-packages/bson/_init_.py", line 558, in decode
(document, _) = _bson_to_dict(self, as_class, tz_aware)
ValueError: microsecond must be in 0..999999