From 495ae9bb053b7694e5b949899bfd0f7a04a3ff51 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 23 Mar 2015 04:03:09 +0100 Subject: [PATCH] Fixed issue with calendar in IDE --- Site5/App_Code/CommonV5.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Site5/App_Code/CommonV5.cs b/Site5/App_Code/CommonV5.cs index 8c759e62..d9f5b321 100644 --- a/Site5/App_Code/CommonV5.cs +++ b/Site5/App_Code/CommonV5.cs @@ -49,13 +49,12 @@ public class CommonV5 }*/ } + GregorianCalendar normalizedCalendar = new GregorianCalendar(); + normalizedCalendar.CalendarType = GregorianCalendarTypes.USEnglish; // avoids problems with Arabic, etc, calendars and bookkeeping in localization + try { - GregorianCalendar normalizedCalendar = new GregorianCalendar(); - normalizedCalendar.CalendarType = GregorianCalendarTypes.USEnglish; // avoids problems with Arabic, etc, calendars and bookkeeping in localization - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(preferredCulture); - Thread.CurrentThread.CurrentCulture.DateTimeFormat.Calendar = normalizedCalendar; } catch (Exception) // if we can't set the culture, what do we do? ("We send the Marines.") { @@ -64,6 +63,17 @@ public class CommonV5 // Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; } + // Set the calendar to GregorianCalendar.USEnglish. This sometimes fails on Windows but works on Mono. If it fails on Windows, no biggie b/c + // this is supposed to be the default anyway. + try + { + Thread.CurrentThread.CurrentCulture.DateTimeFormat.Calendar = normalizedCalendar; + } + catch (Exception) + { + // meh + } + Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; }