From: Marek Safar Date: Mon, 16 Jun 2014 10:52:45 +0000 (+0200) Subject: Merge pull request #1099 from jsportaro/master X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=8f53ba7970cd38449d5bb86801559d4e62b14510;hp=94f466897fa9464a9f1faa0941149c721539358c;p=mono.git Merge pull request #1099 from jsportaro/master Added fix for Bug 11630 --- diff --git a/mcs/class/corlib/System/DateTime.cs b/mcs/class/corlib/System/DateTime.cs index c3da055efc0..30bc6f8edf8 100644 --- a/mcs/class/corlib/System/DateTime.cs +++ b/mcs/class/corlib/System/DateTime.cs @@ -214,6 +214,10 @@ namespace System "yyyy/MMMM", }; + private static readonly string[] ExoticAndNonStandardFormats = new string[] { + "ddMMMyyyy" + }; + private enum Which { Day, @@ -927,6 +931,9 @@ namespace System if (ParseExact (s, dfi.GetAllDateTimePatternsInternal (), dfi, styles, out result, false, ref longYear, setExceptionOnError, ref exception)) return true; + if (ParseExact (s, ExoticAndNonStandardFormats, dfi, styles, out result, false, ref longYear, setExceptionOnError, ref exception)) + return true; + if (!setExceptionOnError) return false; diff --git a/mcs/class/corlib/Test/System/DateTimeTest.cs b/mcs/class/corlib/Test/System/DateTimeTest.cs index 0e7b294f3b9..343e723be82 100644 --- a/mcs/class/corlib/Test/System/DateTimeTest.cs +++ b/mcs/class/corlib/Test/System/DateTimeTest.cs @@ -1216,6 +1216,15 @@ namespace MonoTests.System DateTime.Parse ("Sat,,, 01,,, Oct,,, ,,,1994 03:00:00", CultureInfo.InvariantCulture); } + [Test] + public void TryParse_Bug11630 () + { + DateTime parsed; + + Assert.IsTrue (DateTime.TryParse ("10Feb2013", out parsed)); + Assert.AreEqual (new DateTime (2013, 2, 10), parsed); + } + [Test] [ExpectedException (typeof (FormatException))] public void Parse_CommaAfterHours ()