CallGetCalendarInfoEx() was being called twice even if the first call succeeded ...
authorKeith Newton <bob_corillian@hotmail.com>
Mon, 1 Jun 2020 20:45:24 +0000 (16:45 -0400)
committerGitHub <noreply@github.com>
Mon, 1 Jun 2020 20:45:24 +0000 (13:45 -0700)
* In CalendarData.CheckSpecialCalendar() when the calendar ID is GREGORIAN_US CallGetCalendarInfoEx() was being called twice even if the first call succeeded.

* Update src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs

Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Keith Newton <anony@mous.com>
Co-authored-by: Tarek Mahmoud Sayed <tarekms@microsoft.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs

index a42c872..0d80d68 100644 (file)
@@ -216,13 +216,14 @@ namespace System.Globalization
                     {
                         // Failed, set it to a locale (fa-IR) that's alway has Gregorian US available in the OS
                         localeName = "fa-IR";
-                    }
-                    // See if that works
-                    if (!CallGetCalendarInfoEx(localeName, calendar, CAL_SCALNAME, out string _))
-                    {
-                        // Failed again, just use en-US with the gregorian calendar
-                        localeName = "en-US";
-                        calendar = CalendarId.GREGORIAN;
+
+                        // See if that works
+                        if (!CallGetCalendarInfoEx(localeName, calendar, CAL_SCALNAME, out string _))
+                        {
+                            // Failed again, just use en-US with the gregorian calendar
+                            localeName = "en-US";
+                            calendar = CalendarId.GREGORIAN;
+                        }
                     }
                     break;
                 case CalendarId.TAIWAN: