public void PosTest3() { CultureInfo cultureInfo = new CultureInfo("ja-JP"); DateTimeFormatInfo info = cultureInfo.DateTimeFormat; string expectedEraName = DateTimeFormatInfoData.GetAbbreviatedEraName(cultureInfo); VerificationHelper(info, 1, expectedEraName); }
public static IEnumerable <object[]> CalendarWeekRule_Get_TestData() { yield return(new object[] { DateTimeFormatInfo.InvariantInfo, CalendarWeekRule.FirstDay }); yield return(new object[] { new CultureInfo("en-US").DateTimeFormat, CalendarWeekRule.FirstDay }); yield return(new object[] { new CultureInfo("br-FR").DateTimeFormat, DateTimeFormatInfoData.BrFRCalendarWeekRule() }); }
public void PosTest1() { CultureInfo cultureInfo = new CultureInfo("en-us"); DateTimeFormatInfo info = cultureInfo.DateTimeFormat; string abbreviatedEraName = DateTimeFormatInfoData.GetAbbreviatedEraName(cultureInfo); VerificationHelper(info, 0, abbreviatedEraName); VerificationHelper(info, 1, abbreviatedEraName); }
public void PosTest2(string localeName) { CultureInfo cultureInfo = new CultureInfo(localeName); DateTimeFormatInfo info = cultureInfo.DateTimeFormat; string eraName = DateTimeFormatInfoData.GetEraName(cultureInfo); VerificationHelper(info, 1, eraName); VerificationHelper(info, 0, eraName); }
public void PosTest2(string localeName) { CultureInfo culture = new CultureInfo(localeName); string[] expected = DateTimeFormatInfoData.GetDayNames(culture); DateTimeFormatInfo info = culture.DateTimeFormat; VerificationHelper(info, expected); }
public void TestLocale(string localeName) { CultureInfo myTestCulture = new CultureInfo(localeName); DateTimeFormatInfo dti = myTestCulture.DateTimeFormat; CalendarWeekRule actual = dti.CalendarWeekRule; CalendarWeekRule expected = DateTimeFormatInfoData.GetCalendarWeekRule(myTestCulture); Assert.Equal(expected, actual); }
public static IEnumerable <object[]> GetAbbreviatedEraName_TestData() { yield return(new object[] { new CultureInfo("en-US").DateTimeFormat, 0, DateTimeFormatInfoData.EnUSAbbreviatedEraName() }); yield return(new object[] { new CultureInfo("en-US").DateTimeFormat, 1, DateTimeFormatInfoData.EnUSAbbreviatedEraName() }); yield return(new object[] { new DateTimeFormatInfo(), 0, "AD" }); yield return(new object[] { new DateTimeFormatInfo(), 1, "AD" }); yield return(new object[] { new CultureInfo("ja-JP").DateTimeFormat, 1, DateTimeFormatInfoData.JaJPAbbreviatedEraName() }); }
public static IEnumerable <object[]> GetDayName_TestData() { string[] englishDayNames = new string[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; yield return(new object[] { DateTimeFormatInfo.InvariantInfo, englishDayNames }); yield return(new object[] { new CultureInfo("en-US").DateTimeFormat, englishDayNames }); yield return(new object[] { new DateTimeFormatInfo(), englishDayNames }); if (!PlatformDetection.IsUbuntu) { yield return(new object[] { new CultureInfo("fr-FR").DateTimeFormat, DateTimeFormatInfoData.FrFRDayNames() }); } }
public static IEnumerable <object[]> GetAbbreviatedDayName_TestData() { string[] englishAbbreviatedDayNames = new string[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; yield return(new object[] { DateTimeFormatInfo.InvariantInfo, englishAbbreviatedDayNames }); yield return(new object[] { new CultureInfo("en-US").DateTimeFormat, englishAbbreviatedDayNames }); yield return(new object[] { new DateTimeFormatInfo(), englishAbbreviatedDayNames }); if (!PlatformDetection.IsUbuntu || PlatformDetection.IsUbuntu1404) { yield return(new object[] { new CultureInfo("fr-FR").DateTimeFormat, DateTimeFormatInfoData.FrFRAbbreviatedDayNames() }); } }
public static IEnumerable <object[]> CalendarWeekRule_Get_TestData() { yield return(new object[] { DateTimeFormatInfo.InvariantInfo, CalendarWeekRule.FirstDay }); yield return(new object[] { new CultureInfo("en-US").DateTimeFormat, CalendarWeekRule.FirstDay }); if (PlatformDetection.IsNotBrowser) { yield return(new object[] { new CultureInfo("br-FR").DateTimeFormat, DateTimeFormatInfoData.BrFRCalendarWeekRule() }); } else { // "br-FR" is not presented in Browser's ICU. Let's test ru-RU instead. yield return(new object[] { new CultureInfo("ru-RU").DateTimeFormat, CalendarWeekRule.FirstFourDayWeek }); } }
public static IEnumerable <object[]> GetEraName_TestData() { yield return(new object[] { DateTimeFormatInfo.InvariantInfo, 1, "A.D." }); yield return(new object[] { DateTimeFormatInfo.InvariantInfo, 0, "A.D." }); var enUSFormat = new CultureInfo("en-US").DateTimeFormat; yield return(new object[] { enUSFormat, 1, DateTimeFormatInfoData.EnUSEraName() }); yield return(new object[] { enUSFormat, 0, DateTimeFormatInfoData.EnUSEraName() }); var frRFormat = new CultureInfo("fr-FR").DateTimeFormat; yield return(new object[] { frRFormat, 1, "ap. J.-C." }); yield return(new object[] { frRFormat, 0, "ap. J.-C." }); }
internal static string GetNegativeInfinitySymbol(CultureInfo cultureInfo) { if (s_isWindows && s_WindowsVersion < 10) { if (string.Equals(cultureInfo.Name, "en-US", StringComparison.OrdinalIgnoreCase)) { return("-Infinity"); } if (string.Equals(cultureInfo.Name, "fr-FR", StringComparison.OrdinalIgnoreCase)) { return("-Infini"); } throw DateTimeFormatInfoData.GetCultureNotSupportedException(cultureInfo); } else { return("-\u221E"); } }
public void TestEnUS() { CultureInfo cultureInfo = new CultureInfo("en-us"); DateTimeFormatInfo info = cultureInfo.DateTimeFormat; string eraName = DateTimeFormatInfoData.GetEraName(cultureInfo); string lowerEraName = eraName.ToLower(); string abbrevEraName = DateTimeFormatInfoData.GetAbbreviatedEraName(cultureInfo); string lowerAbbrevEraName = abbrevEraName.ToLower(); VerificationHelper(info, eraName, 1); VerificationHelper(info, lowerEraName, 1); VerificationHelper(info, abbrevEraName, 1); VerificationHelper(info, lowerAbbrevEraName, 1); VerificationHelper(info, "C.E.", -1); VerificationHelper(info, "CE", -1); VerificationHelper(info, "B.C.", -1); VerificationHelper(info, "BC", -1); VerificationHelper(info, "", -1); }
internal static int[] GetCurrencyNegativePatterns(CultureInfo cultureInfo) { // CentOS uses an older ICU than Ubuntu, which means the "Linux" values need to allow for // multiple values, since we can't tell which version of ICU we are using, or whether we are // on CentOS or Ubuntu. // When multiple values are returned, the "older" ICU value is returned last. switch (cultureInfo.Name) { case "en-US": return(s_isWindows ? new int[] { 0 } : new int[] { 1, 0 }); case "en-CA": return(s_isWindows ? new int[] { 1 } : new int[] { 1, 0 }); case "fa-IR": return(s_isWindows ? new int[] { 3 } : new int[] { 1, 0 }); case "fr-CD": if (s_isWindows) { return((s_WindowsVersion < 10) ? new int[] { 4 } : new int[] { 8 }); } else { return(new int[] { 8, 15 }); } case "as": return(s_isWindows ? new int[] { 12 } : new int[] { 9 }); case "es-BO": return((s_isWindows && s_WindowsVersion < 10) ? new int[] { 14 } : new int[] { 1 }); case "fr-CA": return(s_isWindows ? new int[] { 15 } : new int[] { 8, 15 }); } throw DateTimeFormatInfoData.GetCultureNotSupportedException(cultureInfo); }
public static int[] GetNumberGroupSizes(CultureInfo cultureInfo) { if (string.Equals(cultureInfo.Name, "en-US", StringComparison.OrdinalIgnoreCase)) { return(new int[] { 3 }); } if (string.Equals(cultureInfo.Name, "ur-IN", StringComparison.OrdinalIgnoreCase)) { if ((s_isWindows && s_WindowsVersion >= 10) || (s_isOSX && s_OSXKernelVersion >= new Version(15, 0))) { return(new int[] { 3 }); } else { return(new int[] { 3, 2 }); } } throw DateTimeFormatInfoData.GetCultureNotSupportedException(cultureInfo); }
public static IEnumerable <object[]> GetEra_TestData() { yield return(new object[] { DateTimeFormatInfo.InvariantInfo, "A.D.", 1 }); yield return(new object[] { DateTimeFormatInfo.InvariantInfo, "AD", 1 }); yield return(new object[] { DateTimeFormatInfo.InvariantInfo, "a.d.", 1 }); yield return(new object[] { DateTimeFormatInfo.InvariantInfo, "ad", 1 }); yield return(new object[] { DateTimeFormatInfo.InvariantInfo, "C.E", -1 }); yield return(new object[] { DateTimeFormatInfo.InvariantInfo, "CE", -1 }); yield return(new object[] { DateTimeFormatInfo.InvariantInfo, "B.C", -1 }); yield return(new object[] { DateTimeFormatInfo.InvariantInfo, "BC", -1 }); yield return(new object[] { DateTimeFormatInfo.InvariantInfo, "", -1 }); var enUSFormat = new CultureInfo("en-US").DateTimeFormat; yield return(new object[] { enUSFormat, DateTimeFormatInfoData.EnUSEraName(), 1 }); yield return(new object[] { enUSFormat, DateTimeFormatInfoData.EnUSEraName().ToLower(), 1 }); yield return(new object[] { enUSFormat, DateTimeFormatInfoData.EnUSAbbreviatedEraName(), 1 }); yield return(new object[] { enUSFormat, DateTimeFormatInfoData.EnUSAbbreviatedEraName().ToLower(), 1 }); yield return(new object[] { enUSFormat, "C.E", -1 }); yield return(new object[] { enUSFormat, "CE", -1 }); yield return(new object[] { enUSFormat, "B.C", -1 }); yield return(new object[] { enUSFormat, "BC", -1 }); yield return(new object[] { enUSFormat, "", -1 }); // For Win7, "fr-FR" is "ap J.-C". // For windows<Win7 & MAC, every culture is "A.D." var frFRFormat = new CultureInfo("fr-FR").DateTimeFormat; yield return(new object[] { frFRFormat, "A.D.", -1 }); yield return(new object[] { frFRFormat, "AD", -1 }); yield return(new object[] { frFRFormat, "a.d.", -1 }); yield return(new object[] { frFRFormat, "ad", -1 }); yield return(new object[] { frFRFormat, "C.E", -1 }); yield return(new object[] { frFRFormat, "CE", -1 }); yield return(new object[] { frFRFormat, "B.C", -1 }); yield return(new object[] { frFRFormat, "BC", -1 }); yield return(new object[] { frFRFormat, "ap. J.-C.", 1 }); yield return(new object[] { frFRFormat, "AP. J.-C.", 1 }); yield return(new object[] { frFRFormat, "ap. j.-c.", 1 }); yield return(new object[] { frFRFormat, "ap J-C", -1 }); }