In Australia, A client has been entering "1/5"
as a shortcut for the first day of May. We have just moved from Windows Server 2008 to Windows Server 2012.
Using the following code in LinqPad:
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-au", false);
System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthDayPattern.Dump();
DateTime.Parse("1/5").Dump();
On Windows Server 2008:
dd MMMM
1/05/2016 12:00:00 AM
On Windows Server 2012 R2:
MMMM d
5/01/2016 12:00:00 AM
Questions:
DateTime.Parse
happening all through the system (Eg. Model Binding, Validation etc)I can replicate the issue on Windows Server 2012. If you add...
System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern.Dump();
you'll see it returns...
d/MM/yyyy
It's only the MonthDayPattern which seems to be incorrect. This might be a bug. I would log the issue on https://connect.microsoft.com/.
In the mean time you could simply set the MonthDayPattern....
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-au", false);
System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern.Dump();
System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthDayPattern.Dump();
DateTime.Parse("1/5").Dump();
System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthDayPattern = "d MMMM";
DateTime.Parse("1/5").Dump();
On Windows Server 2012 R2:
d/MM/yyyy
MMMM d
5/01/2016 12:00:00 AM
1/05/2016 12:00:00 AM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With