Bug 3392 - [PATCH] DateTimeOffset.Parse ""2012-01-14T15:09:42.692875+03:00"" throws FormatException
Summary: [PATCH] DateTimeOffset.Parse ""2012-01-14T15:09:42.692875+03:00"" throws Form...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 2.10.x
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-02-10 16:10 UTC by Tom Hindle
Modified: 2016-04-16 08:14 UTC (History)
4 users (show)

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


Attachments
Test Program that display bug. (325 bytes, text/plain)
2012-02-10 16:10 UTC, Tom Hindle
Details
Unittest and fix for Review. (1.20 KB, patch)
2012-03-09 16:41 UTC, Tom Hindle
Details
Improvement on the previous patch. (571 bytes, patch)
2012-05-03 12:41 UTC, Tom Hindle
Details


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 Tom Hindle 2012-02-10 16:10:49 UTC
Created attachment 1345 [details]
Test Program that display bug.

Tested on mono 2.10.8

Expected result:
14/01/2012 3:09:42 PM +03:00

Actual result:

Unhandled Exception: System.FormatException: String was not recognized as a valid DateTime.
  at System.DateTimeOffset.Parse (System.String input, IFormatProvider formatProvider, DateTimeStyles styles) [0x00000] in <filename unknown>:0
  at DateTimeOffsetTryParseTest.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.FormatException: String was not recognized as a valid DateTime.
  at System.DateTimeOffset.Parse (System.String input, IFormatProvider formatProvider, DateTimeStyles styles) [0x00000] in <filename unknown>:0
  at DateTimeOffsetTryParseTest.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Tom Hindle 2012-03-09 16:41:13 UTC
Created attachment 1490 [details]
Unittest and fix for Review.
Comment 2 Gonzalo Paniagua Javier 2012-03-09 23:45:53 UTC
Patch applied to master/3ed1da7 and mono-2-10/f1ffa65

Thanks!
Comment 3 Tom Hindle 2012-05-03 12:41:52 UTC
Created attachment 1802 [details]
Improvement on the previous patch.

Previous patch was incomplete. 

For example it didn't deal with: 
"2011-09-05T13:45:03.3125+03:00"
Comment 4 xamarin 2013-01-24 10:56:02 UTC
This should still be resolved. The following sample still doesnt work on the latest version of monotouch 

public static void Main (string[] args)
{
	string sampleDate = "2013-01-24T15:55:21.7625+01:00";
	
	DateTime date1;
	DateTime date2;
			
	//doesnt work on monotouch, does work on windows
	var result1 = DateTime.TryParse(sampleDate, CultureInfo.InvariantCulture, DateTimeStyles.None, out date1);
			
	//does work on all platforms	
	var result2 = DateTime.TryParse(sampleDate, out date2);

	Console.ReadLine ();
}
Comment 5 Marek Safar 2016-04-16 08:14:27 UTC
Works with the latest version