[CSHARP-4694] $dateToString aggregation with timezone outputs invalid ISO8601 string on older servers Created: 27/Jun/23  Updated: 28/Oct/23  Resolved: 04/Jul/23

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 2.21.0

Type: Improvement Priority: Major - P3
Reporter: PM Bot Assignee: Robert Stam
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
Server Compat: 7.1
Upstream Changes Summary:

DRIVERS-2620:
The current default behavior of MongoDB's $dateToString aggregation expression is incorrect because it violates ISO 8601. (It tacks on a "Z" to the end of the string by default, which implies that it is in UTC [1], but in actually it's in the timezone of the local server.)

This ticket proposes a number of routes to change the default behavior of $dateToString to bring it into compliance with ISO 8601.

[1] https://en.wikipedia.org/wiki/ISO_8601#Coordinated_Universal_Time_(UTC)

1. If the query specifies a date format string, this is used.
2. If no format string is specified, then
a. If no timezone is specified or the UTC timezone is explicitly specified, the default format will continue to include the 'Z' suffix (yyyy-mm-ddThh:mm:ss.uuuZ).
b. If a non-UTC timezone is specified, the default format will omit the 'Z' suffix (yyyy-mm-ddThh:mm:ss.uuu).

Case 2b is the only change from prior behavior.

This change was delivered in 7.1.0-rc0 and will NOT be backported.

Documentation Changes: Not Needed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

This ticket was split from DRIVERS-2620, please see that ticket for a detailed description.



 Comments   
Comment by Githook User [ 04/Jul/23 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4694: Fix a few $dateToString tests on latest.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/a9bad55e36e0c7211d9bf74a75790990e11dbf54

Comment by Robert Stam [ 29/Jun/23 ]

I think the part of the description that states:

but in actually it's in the timezone of the local server

is wrong. It should read: "but in actuality it's in the timezone specified by the timezone argument".

Generated at Wed Feb 07 21:49:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.