[GODRIVER-1001] Current time zone mode for time.Time handling wrt timezones Created: 26/Apr/19 Updated: 27/Oct/23 Resolved: 24/Jul/20 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Sam Kleinman (Inactive) | Assignee: | Unassigned |
| Resolution: | Gone away | Votes: | 0 |
| Labels: | evg | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
the evergreen team observes that timezones are handled differently with the new bson library relative to mgobson. I don't think there's a problem in terms of correctness, but it causes our tests to fail in ways that are irritating, and requires some context in order to fix. I believe that mgobson converted time.Time back to the current time zone, and the new driver leaves them in UTC. This should be fully documented in any migration material, and potentially in the API documentation, but it might be nice to build/provide a set of codecs for compatibility mode, to reduce migration friction. |
| Comments |
| Comment by Isabella Siu (Inactive) [ 17/Oct/19 ] | ||||||||||||||||||||||||||||||||
|
I'm going to remove this from the mgocompat epic, as this isn't a compatibility problem with globalsign's mgo, but I will leave this open, as we are open to adding non-mgocompat options to the codecs in the future. | ||||||||||||||||||||||||||||||||
| Comment by Sam Kleinman (Inactive) [ 16/Oct/19 ] | ||||||||||||||||||||||||||||||||
|
I was using our (10gen) fork rather than the globalsign one, your code keeps it in EDT for me:
| ||||||||||||||||||||||||||||||||
| Comment by Isabella Siu (Inactive) [ 16/Oct/19 ] | ||||||||||||||||||||||||||||||||
|
I'm using the master branch of "github.com/globalsign/mgo/bson" and it changed to UTC. Maybe we're using different mgo versions or calling a different function? Can you show me the test code that reproduces your issue? The code I used is below:
| ||||||||||||||||||||||||||||||||
| Comment by Sam Kleinman (Inactive) [ 16/Oct/19 ] | ||||||||||||||||||||||||||||||||
|
Yes exactly. The behavior is different in mgo | ||||||||||||||||||||||||||||||||
| Comment by Isabella Siu (Inactive) [ 16/Oct/19 ] | ||||||||||||||||||||||||||||||||
|
Hi sam.kleinman, Can you give us a repro of this? When I marshaled and unmarshaled a time.Time using mgobson it went from EDT to UTC. | ||||||||||||||||||||||||||||||||
| Comment by Bernie Hackett [ 26/Apr/19 ] | ||||||||||||||||||||||||||||||||
|
As a point of comparison, PyMongo gives you datetimes in UTC by default, but if you configure a timezone (and have pytz installed in the python environment) we'll give you back datetimes in whatever local time you configure. https://api.mongodb.com/python/current/examples/datetimes.html#saving-datetimes-with-timezones |