Bug 19879 - DateTime.ParseExact failing on good date format
Summary: DateTime.ParseExact failing on good date format
Status: RESOLVED FEATURE
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 3.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-05-18 22:00 UTC by Apollo Grace
Modified: 2014-05-29 11:44 UTC (History)
4 users (show)

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


Attachments
Hello world, with code to show the bug added. (311 bytes, application/octet-stream)
2014-05-18 22:00 UTC, Apollo Grace
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 FEATURE

Description Apollo Grace 2014-05-18 22:00:59 UTC
Created attachment 6832 [details]
Hello world, with code to show the bug added.

I've been porting a Windows project that reads date strings with the format "ddd MMM dd HH:mm:ss yyyy".  This format raises an InvalidFormatException in Mono.
Comment 1 Zoltan Varga 2014-05-19 07:02:39 UTC
-> class libs
Comment 2 marcos.henrich 2014-05-26 10:49:58 UTC
Hi Apollo,

The format dd should be used for 2 digit numbers from 01 through 31, a 0 should precede numbers less than 10.

The format "ddd MMM dd HH:mm:ss yyyy" is expecting something like "Sat May 03 08:00:35 2014".
To parse "Sat May  3 08:00:35 2014", 
ParseExact should be called with the format "ddd MMM d HH:mm:ss yyyy" and DateTimeStyles.AllowInnerWhite.
Comment 3 Marek Safar 2014-05-29 04:17:46 UTC
.NET throws same exception
Comment 4 Apollo Grace 2014-05-29 11:44:16 UTC
Ah, verified.  Mea culpa, I'm sorry.  The Windows machine actually had different data for my program (it had the May 03 format), and I didn't try out my "hello.cs" test case on Windows.

Sorry to waste time in the bug system, but very grateful for the education in DateFormat.ParseExact, and also for the reminder of how to test a bug properly before submitting it.  I intend to do a lot of work in Mono, and hope to be able to contribute to the platform; I'll do better in future.