Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue in datetime #64

Open
srinivasreddy opened this issue Jul 13, 2017 · 2 comments
Open

issue in datetime #64

srinivasreddy opened this issue Jul 13, 2017 · 2 comments

Comments

@srinivasreddy
Copy link

>>> import bson
>>> from bson import json_util
>>> from datetime import datetime
>>> k = datetime.now()
>>> k
datetime.datetime(2017, 7, 12, 20, 7, 44, 694669)
>>> json_util.dumps(k)
'{"$date": 1499890064694}'
>>> json_util.loads(json_util.dumps(k))
datetime.datetime(2017, 7, 12, 20, 7, 44, 694000, tzinfo=<bson.tz_util.FixedOffset object at 0x237d750>)
>>> j = json_util.loads(json_util.dumps(k))
>>> k ==j 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't compare offset-naive and offset-aware datetimes
>>> 

I think we should respect the datetime as is whether it has timezone or it is naive.

@Parkayun
Copy link
Member

Nice idea :)

@kayakMike
Copy link

This is for the DATETIME type? Curious about the TIMESTAMP, it looks like this one is a signed 64 bit integer. Should it be unsigned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants