[SERVER-29209] Add TZ support to the new $dateFromString A/F operator Created: 15/May/17  Updated: 30/Oct/23  Resolved: 21/Jul/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework, Querying
Affects Version/s: None
Fix Version/s: 3.5.11

Type: Task Priority: Major - P3
Reporter: Derick Rethans Assignee: Derick Rethans
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-29208 Add the $dateFromString A/F operator ... Closed
Documented
is documented by DOCS-10567 Docs for SERVER-29209: Add TZ support... Closed
Related
related to SERVER-4434 aggregation: add strptime functional... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 2017-07-10, Query 2017-07-31
Participants:

 Description   

This features adds a new Aggregation Framework operator $dateFromString.

It has the following syntax:

{ "$dateFromString": { "dateString": dateString, "timezone": timeZoneIdentifier } }

The dateString could be anything like:

  • 2017-08-04T17:02:51Z
  • August 4, 2017 17:10:27.812+0100

The "timezone" argument is optional, and can either specify an Olson Timezone Identifier such as "Europe/London" or "America/New_York", or, it can be a UTC offset in the forms: "+03", "-0530", and "+04:45". If you specify a timezone argument it means that the dateString that you provided will be interpreted as it was in that time zone.

For example:

{ $dateFromString: { dateString: "2017-08-04T17:06:41.113", timezone: "Europe/London" } }

Would mean 17:06 local time in London, or 16:06 in UTC (as London right now is at UTC+1).

It is not allowed to specify a time zone through the dateString (such as the ending "Z" or "+0400") and also specify a time zone through the timezone argument. In that case, an exception is thrown.



 Comments   
Comment by Githook User [ 21/Jul/17 ]

Author:

{u'username': u'derickr', u'name': u'Derick Rethans', u'email': u'github@derickrethans.nl'}

Message: SERVER-29209 Add timezone support to $dateFromString
Branch: master
https://github.com/mongodb/mongo/commit/edc9f4c74a57db45e82c93f714b093336e88744b

Generated at Thu Feb 08 04:20:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.