Bug 22851 - DateTimeOffset.Parse() doesn't handle RFC1123 formatted timestamps correctly
Summary: DateTimeOffset.Parse() doesn't handle RFC1123 formatted timestamps correctly
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 3.8.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
URL:
Depends on:
Blocks:
 
Reported: 2014-09-10 19:15 UTC by Craig Minihan
Modified: 2014-09-11 10:37 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Craig Minihan 2014-09-10 19:15:38 UTC
DateTimeOffset does not correctly handle RFC1123 formatted timestamps as in the following example:

    var t = DateTimeOffset.Parse("Wed, 10 Sep 2014 22:01:40 GMT");
    var t1 = t.ToString();
    var t2 = t.ToString("r");

On Mono we see:
t1 = "9/10/2014 10:01:40 PM +02:00"
t2 = "Wed, 10 Sep 2014 20:01:40 GMT"

.NET 4.5 shows:
t1 = "9/10/2014 10:01:40 PM +00:00"
t2 = "Wed, 10 Sep 2014 22:01:40 GMT"

In both examples t2 should exactly match the original RFC1123 timestamp, however in Mono time has been shifted by two hours (the UTC offset of the machine where the test ran). 

On a machine running in EDT:
t1 = "9/10/2014 10:01:40 PM -04:00"
t2 = "Thu, 11 Sep 2014 02:01:40 GMT"

And now we are out by 4 hours.
Comment 1 marcos.henrich 2014-09-11 10:15:14 UTC
Hi Craig,

Thank you for the detailed bug report.

The pull request for this issue can be found in the link below.
https://github.com/mono/mono/pull/1278
Comment 2 marcos.henrich 2014-09-11 10:37:39 UTC
Fixed in master 0083728e199bfa37fc9867654d3571b9a0b1df09.
https://github.com/mono/mono/commit/0083728e199bfa37fc9867654d3571b9a0b1df09