internal static DateTimeFormatInfo GetDateFormat(CultureInfo culture) { // Check for persian first if (culture.LCID == 1065) { return(PersianCalendarHelper.GetDateTimeFormatInfo()); } if (culture.Calendar is GregorianCalendar) { return(culture.DateTimeFormat); } else { GregorianCalendar foundCal = null; DateTimeFormatInfo dtfi = null; foreach (System.Globalization.Calendar cal in culture.OptionalCalendars) { if (cal is GregorianCalendar) { // Return the first Gregorian calendar with CalendarType == Localized // Otherwise return the first Gregorian calendar if (foundCal == null) { foundCal = cal as GregorianCalendar; } if (((GregorianCalendar)cal).CalendarType == GregorianCalendarTypes.Localized) { foundCal = cal as GregorianCalendar; break; } } } if (foundCal == null) { // if there are no GregorianCalendars in the OptionalCalendars list, use the invariant dtfi dtfi = ((CultureInfo)CultureInfo.InvariantCulture.Clone()).DateTimeFormat; dtfi.Calendar = new GregorianCalendar(); } else { dtfi = ((CultureInfo)culture.Clone()).DateTimeFormat; dtfi.Calendar = foundCal; } return(dtfi); } }
internal static DateTimeFormatInfo GetDateFormat(CultureInfo culture) { return(PersianCalendarHelper.GetDateTimeFormatInfo()); }