[SERVER-3441] Timezones with "+hh:mm" or "-hh:mm" work, but those with "Z" don't Created: 18/Jul/11 Updated: 29/Aug/11 Resolved: 18/Jul/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 1.8.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Seamus Abshere | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | standards, timezone | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
According to the W3C (http://www.w3.org/TR/NOTE-datetime) and the IETF (http://tools.ietf.org/html/rfc3339), both ways of representing time zones should be accepted:
The first way (2011-07-18T08:35:21-05:00) works just fine: mydbset:PRIMARY> db.MyCollection.find({"started_at":{"$gte":"2011-07-18T08:35:21-05:00","$lt":"2011-07-18T12:35:21-05:00"}}).count() } The second way (2011-07-18T13:35:21Z) fails silently: mydbset:PRIMARY> db.MyCollection.find({"started_at":{"$gte":"2011-07-18T13:35:21Z","$lt":"2011-07-18T17:35:21Z"}}).count() } This causes particular problems with the mongo-ruby-driver because Time.now.utc.to_json gives the non-working form: require 'active_support' { :started_at => Time.now.utc }.to_json #=> {"started_at":"2011-07-18T19:15:37Z"} |
| Comments |
| Comment by Seamus Abshere [ 18/Jul/11 ] |
|
Thanks for clarifying this. It appears that the dates have been stored as Strings on the server itself, which is the source of this problem. |
| Comment by Scott Hernandez (Inactive) [ 18/Jul/11 ] |
|
Strings are not Dates, and they are not compatible when used in queries. >new ISODate("2011-07-18T13:35:21Z") In ruby that is just pretty printing and not what gets sent to the server. |