Norwegian culture problem - Date parsing - by Morten Abrahamsen

Status : 

 


48
0
Sign in
to vote
ID 1621722 Comments
Status Active Workarounds
Type Bug Repros 8
Opened 8/3/2015 5:27:59 AM
Access Restriction Public

Description

This used to work fine on Windows 8.1 and .Net FX 4.5.2 (VS2013):

            var dt = DateTime.Parse("24.12.2012", new CultureInfo("nb-NO"));

This is a perfectly valid Norwegian culture date format, meaning the 24th of Dec 2012.

Using Windows 10 Enterprise US English Edition and VS 2015 this works building as a .Net 2.0 project, but fails with any .Net 4.0-4.6 project.

---

This doesn't work either, for the record:
            var culture = new CultureInfo("nb-NO");
            string s = new DateTime(2012, 12, 24).ToString(culture);
            DateTime.Parse(s, culture);


Sign in to post a comment.
Posted by Tushar Bhagat on 1/11/2017 at 12:07 AM
We are clueless about resolution of this issue. Multiple web sites provide reference of KB 30811448 which contains fix for this issue.. But I didn't find anywhere that this patch resolved issue. Can anyone has idea about it?
Posted by CRF1 on 3/11/2016 at 12:39 PM
Did this issue get resolved, most dates work with exception of
13-02-2016 10:28:54 and a few others.... I wish i had a as big a team as MS to look at such trivial yet disturbing issues!
Posted by Tarek [MSFT] on 9/21/2015 at 10:19 AM
Planning to release the fix soon with the next Windows Update.
Posted by Niklas Korhonen on 8/28/2015 at 4:14 AM
easy to reproduce with code:
        Dim s As String = Date.Now.ToShortDateString
        Dim d As Date
        Dim b As Boolean = Date.TryParse(s, d)
        Debug.Print(s.ToString & " " & b.ToString & " " & d.ToString)

default Finnish Finland locale settings
windows 10: 28.8.2015 False 1.1.0001 0.00.00
windows 7: 28.8.2015 True 28.8.2015 0:00:00
Posted by JouniHeikniemi on 8/26/2015 at 10:13 PM
According to the team, this issue has been fixed. While waiting for the Connect issue to be updated, please read my blog post at http://www.heikniemi.net/hardcoded/2015/08/windows-10-breaks-net-date-parsing-in-certain-locales/ for further information.
Posted by Morten Abrahamsen on 8/25/2015 at 5:14 AM
Ref: https://github.com/dotnet/coreclr/issues/1322
Posted by K Johan I Olsson on 8/25/2015 at 12:28 AM
To Paul R Hills list i would to add:
Estonian - Estonia

This culture also uses the same TimeSeparator & DateSeparator.

Full list (at this time):
Estonian (Estonia)
Finnish (Finland)
Norwegian Bokmål (Norway)
Norwegian Bokmål (Svalbard and Jan Mayen)
Serbian (Cyrillic, Kosovo)
Serbian (Latin, Montenegro)
Serbian (Latin, Serbia)
Serbian (Latin, Kosovo)
Posted by JouniHeikniemi on 8/9/2015 at 9:28 PM
Yes. The essence here seems to be that if your locale has the same date and time separator, non-exact DateTime.Parse fails. This breaks stuff like WPF data binding and ASP.NET MVC model binding as well as a bunch of imperative parsing code. Microsoft is aware of the seriousness of the issue.
Posted by Microsoft on 8/8/2015 at 8:07 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If you require immediate assistance with this issue, please contact product support at http://support.microsoft.com/oas/default.aspx?prid=15694.
Posted by kenroen on 8/4/2015 at 5:34 AM
I have the same problem
Posted by Paul R Hill on 8/4/2015 at 4:26 AM
I too have this problem. The following cultures are effected:

Finnish (Finland)
Norwegian Bokmål (Norway)
Norwegian Bokmål (Svalbard and Jan Mayen)
Serbian (Cyrillic, Kosovo)
Serbian (Latin, Montenegro)
Serbian (Latin, Serbia)
Serbian (Latin, Kosovo)

These cultures all use the same TimeSeparator & DateSeparator.

The documentation for Convert.ToDateTime() specifies "If value contains only a date and no time, this method assumes a time of midnight."
See: https://msdn.microsoft.com/en-us/library/xhz1w05e(v=vs.110).aspx

This is not true for the locales listed above.
Both Convert.ToDateTime() and DateTime.Parse() cannot parse a date only.
Posted by Juan Antonio Ortega Rejon on 8/3/2015 at 5:33 AM
I can reproduce this bug too