public void PosTest3()
        {
            CultureInfo        cultureInfo     = new CultureInfo("ja-JP");
            DateTimeFormatInfo info            = cultureInfo.DateTimeFormat;
            string             expectedEraName = DateTimeFormatInfoData.GetAbbreviatedEraName(cultureInfo);

            VerificationHelper(info, 1, expectedEraName);
        }
コード例 #2
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void PosTest2(string localeName)
        {
            CultureInfo culture = new CultureInfo(localeName);

            string[] expected = DateTimeFormatInfoData.GetDayNames(culture);

            DateTimeFormatInfo info = culture.DateTimeFormat;

            VerificationHelper(info, expected);
        }
コード例 #6
0
        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() });
        }
コード例 #8
0
        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() });
            }
        }
コード例 #9
0
        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() });
            }
        }
コード例 #10
0
        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 });
            }
        }
コード例 #11
0
        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." });
        }
コード例 #12
0
        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");
            }
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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 });
        }