예제 #1
0
    public static Calendar GregorianCalendar(GregorianCalendarTypes Type)
    {
        CultureInfo ci = null;

        switch (Type)
        {
            case GregorianCalendarTypes.Arabic:
                ci = new CultureInfo("ar-SA");
                return ci.OptionalCalendars[4];
            case GregorianCalendarTypes.Localized:
                ci = new CultureInfo("ar-IQ");
                return ci.OptionalCalendars[0];
            case GregorianCalendarTypes.MiddleEastFrench:
                ci = new CultureInfo("ar-IQ");
                return ci.OptionalCalendars[4];
            case GregorianCalendarTypes.TransliteratedEnglish:
                ci = new CultureInfo("ar-IQ");
                return ci.OptionalCalendars[5];
            case GregorianCalendarTypes.TransliteratedFrench:
                ci = new CultureInfo("ar-IQ");
                return ci.OptionalCalendars[6];
            case GregorianCalendarTypes.USEnglish:
                ci = new CultureInfo("ar-IQ");
                return ci.OptionalCalendars[3];
            default:
                throw new NotImplementedException();
        }
    }
예제 #2
0
        public void CalendarType_Set(GregorianCalendarTypes type)
        {
            GregorianCalendar calendar = ((GregorianCalendar)Calendar);

            calendar.CalendarType = type;
            Assert.Equal(type, calendar.CalendarType);
        }
예제 #3
0
        public void Ctor_GregorianCalendarType(GregorianCalendarTypes type)
        {
            GregorianCalendar calendar = new GregorianCalendar(type);

            Assert.Equal(type, calendar.CalendarType);
            Assert.False(calendar.IsReadOnly);
        }
예제 #4
0
 private static bool ValidateCalendar(CultureInfo langauge, bool isGregorianSubType, Calendar calendar)
 {
     if (calendar == null)
     {
         return(false);
     }
     Calendar[] optionalCalendars = langauge.OptionalCalendars;
     if (optionalCalendars != null)
     {
         for (int i = 0; i < optionalCalendars.Length; i++)
         {
             if (optionalCalendars[i].GetType() == calendar.GetType())
             {
                 if (!isGregorianSubType)
                 {
                     return(true);
                 }
                 GregorianCalendarTypes calendarType  = ((GregorianCalendar)calendar).CalendarType;
                 GregorianCalendarTypes calendarType2 = ((GregorianCalendar)optionalCalendars[i]).CalendarType;
                 if (calendarType == calendarType2)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
예제 #5
0
        public void ToFourDigitYear(GregorianCalendarTypes calendarType, int year)
        {
            Calendar calendar = new GregorianCalendar(calendarType);
            int      expected = GetExpectedFourDigitYear(calendar, year);

            Assert.Equal(expected, calendar.ToFourDigitYear(year));
        }
        public static IEnumerable <object[]> ToFourDigitYear_TestData()
        {
            GregorianCalendarTypes[] calendarTypes = new GregorianCalendarTypes[]
            {
                GregorianCalendarTypes.Arabic,
                GregorianCalendarTypes.Localized,
                GregorianCalendarTypes.MiddleEastFrench,
                GregorianCalendarTypes.TransliteratedEnglish,
                GregorianCalendarTypes.TransliteratedFrench,
                GregorianCalendarTypes.USEnglish
            };

            foreach (GregorianCalendarTypes calendarType in calendarTypes)
            {
                // 0-99
                int randomTwoDigitYear = s_randomDataGenerator.GetInt32(-55) % (MaxTwoDigitYear + 1);
                yield return(new object[] { calendarType, randomTwoDigitYear, GetExpectedFourDigitYear(calendarType, randomTwoDigitYear) });

                // Min two digit year
                yield return(new object[] { calendarType, MinTwoDigitYear, GetExpectedFourDigitYear(calendarType, MinTwoDigitYear) });

                // Max two digit year
                yield return(new object[] { calendarType, MaxTwoDigitYear, GetExpectedFourDigitYear(calendarType, MaxTwoDigitYear) });
            }
        }
예제 #7
0
    public static Calendar GregorianCalendar(GregorianCalendarTypes Type)
    {
        CultureInfo ci = null;

        switch (Type)
        {
        case GregorianCalendarTypes.Arabic:
            ci = new CultureInfo("ar-SA");
            return(ci.OptionalCalendars[4]);

        case GregorianCalendarTypes.Localized:
            ci = new CultureInfo("ar-IQ");
            return(ci.OptionalCalendars[0]);

        case GregorianCalendarTypes.MiddleEastFrench:
            ci = new CultureInfo("ar-IQ");
            return(ci.OptionalCalendars[4]);

        case GregorianCalendarTypes.TransliteratedEnglish:
            ci = new CultureInfo("ar-IQ");
            return(ci.OptionalCalendars[5]);

        case GregorianCalendarTypes.TransliteratedFrench:
            ci = new CultureInfo("ar-IQ");
            return(ci.OptionalCalendars[6]);

        case GregorianCalendarTypes.USEnglish:
            ci = new CultureInfo("ar-IQ");
            return(ci.OptionalCalendars[3]);

        default:
            throw new NotImplementedException();
        }
    }
 private void PosTest1(GregorianCalendarTypes calendarType)
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
     int expectedTwoDigitYearMax, actualTwoDigitYearMax;
     expectedTwoDigitYearMax = c_DEFAULT_TWO_DIGIT_YEAR_MAX;
     actualTwoDigitYearMax = myCalendar.TwoDigitYearMax;
     Assert.Equal(expectedTwoDigitYearMax, actualTwoDigitYearMax);
 }
예제 #9
0
 public GregorianCalendar(GregorianCalendarTypes type)
 {
     if ((type < GregorianCalendarTypes.Localized) || (type > GregorianCalendarTypes.TransliteratedFrench))
     {
         throw new ArgumentOutOfRangeException("type", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), new object[] { GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench }));
     }
     this.m_type = type;
 }
예제 #10
0
 public GregorianCalendar(GregorianCalendarTypes type)
 {
     if ((type < GregorianCalendarTypes.Localized) || (type > GregorianCalendarTypes.TransliteratedFrench))
     {
         throw new ArgumentOutOfRangeException("type", Environment.GetResourceString("ArgumentOutOfRange_Range", new object[] { GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench }));
     }
     this.m_type = type;
 }
 // PosTest: Get the MaxSupportedDateTime of Gregorian calendar
 private void PosTest(GregorianCalendarTypes calendarType)
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
     DateTime expectedTime, actualTime;
     expectedTime = DateTime.MaxValue;
     actualTime = myCalendar.MaxSupportedDateTime;
     Assert.Equal(expectedTime, actualTime);
 }
예제 #12
0
 private void PosTest(GregorianCalendarTypes calendarType)
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
     int[] expectedEras, actualEras;
     expectedEras = s_ADEra;
     actualEras   = myCalendar.Eras;
     Assert.Equal(expectedEras.Length, actualEras.Length);
     Assert.Equal(expectedEras[0], actualEras[0]);
 }
        public void ToFourDigitYear(GregorianCalendarTypes calendarType)
        {
            Calendar calendar = new GregorianCalendar(calendarType);
            Assert.Equal(DefaultTwoDigitMax, calendar.TwoDigitYearMax);

            int randomTwoDigitYearMax = MinTwoDigitYear + s_randomDataGenerator.GetInt32(-55) % (MaxYear - MinTwoDigitYear + 1);
            calendar.TwoDigitYearMax = randomTwoDigitYearMax;
            Assert.Equal(randomTwoDigitYearMax, calendar.TwoDigitYearMax);
        }
예제 #14
0
 private void PosTest(GregorianCalendarTypes calendarType)
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
     int[] expectedEras, actualEras;
     expectedEras = s_ADEra;
     actualEras = myCalendar.Eras;
     Assert.Equal(expectedEras.Length, actualEras.Length);
     Assert.Equal(expectedEras[0], actualEras[0]);
 }
예제 #15
0
        private void PosTest1(GregorianCalendarTypes calendarType)
        {
            System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
            int expectedTwoDigitYearMax, actualTwoDigitYearMax;

            expectedTwoDigitYearMax = c_DEFAULT_TWO_DIGIT_YEAR_MAX;
            actualTwoDigitYearMax   = myCalendar.TwoDigitYearMax;
            Assert.Equal(expectedTwoDigitYearMax, actualTwoDigitYearMax);
        }
 private void PosTest2(GregorianCalendarTypes calendarType)
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
     int expectedTwoDigitYearMax, actualTwoDigitYearMax;
     expectedTwoDigitYearMax = c_MIN_TWO_DIGIT_YEAR + TestLibrary.Generator.GetInt32(-55) % (c_MAX_YEAR - c_MIN_TWO_DIGIT_YEAR + 1);
     myCalendar.TwoDigitYearMax = expectedTwoDigitYearMax;
     actualTwoDigitYearMax = myCalendar.TwoDigitYearMax;
     Assert.Equal(expectedTwoDigitYearMax, actualTwoDigitYearMax);
 }
        // PosTest: Get the MaxSupportedDateTime of Gregorian calendar
        private void PosTest(GregorianCalendarTypes calendarType)
        {
            System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
            DateTime expectedTime, actualTime;

            expectedTime = DateTime.MaxValue;
            actualTime   = myCalendar.MaxSupportedDateTime;
            Assert.Equal(expectedTime, actualTime);
        }
 /// <summary>
 /// Constructor that sets the
 /// Gregorian calendar type (
 /// <see cref="T:System.Globalization.GregorianCalendarTypes"/>).
 /// </summary>
 /// <param name="type">The parameter specifies the Gregorian
 /// calendar type.
 /// </param>
 public GregorianCalendar(GregorianCalendarTypes type)
 {
     CalendarType   = type;
     M_AbbrEraNames = new string[] { "AD" };
     M_EraNames     = new string[] { "A.D." };
     if (twoDigitYearMax == 99)
     {
         twoDigitYearMax = 2029;
     }
 }
 private void PosTest3(GregorianCalendarTypes calendarType)
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
     int twoDigitYear;
     int expectedFourDigitYear, actualFourDigitYear;
     twoDigitYear = c_MIN_TWO_DIGIT_YEAR;
     expectedFourDigitYear = GetExpectedFourDigitYear(myCalendar, twoDigitYear);
     actualFourDigitYear = myCalendar.ToFourDigitYear(twoDigitYear);
     Assert.Equal(expectedFourDigitYear, actualFourDigitYear);
 }
 private void PosTest1(GregorianCalendarTypes calendarType)
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
     int twoDigitYear;
     int expectedFourDigitYear, actualFourDigitYear;
     twoDigitYear = TestLibrary.Generator.GetInt32(-55) % (c_MAX_TWO_DIGIT_YEAR + 1);
     expectedFourDigitYear = GetExpectedFourDigitYear(myCalendar, twoDigitYear);
     actualFourDigitYear = myCalendar.ToFourDigitYear(twoDigitYear);
     Assert.Equal(expectedFourDigitYear, actualFourDigitYear);
 }
예제 #21
0
        private void PosTest2(GregorianCalendarTypes calendarType)
        {
            System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
            int expectedTwoDigitYearMax, actualTwoDigitYearMax;

            expectedTwoDigitYearMax    = c_MIN_TWO_DIGIT_YEAR + _generator.GetInt32(-55) % (c_MAX_YEAR - c_MIN_TWO_DIGIT_YEAR + 1);
            myCalendar.TwoDigitYearMax = expectedTwoDigitYearMax;
            actualTwoDigitYearMax      = myCalendar.TwoDigitYearMax;
            Assert.Equal(expectedTwoDigitYearMax, actualTwoDigitYearMax);
        }
예제 #22
0
        private void PosTest3(GregorianCalendarTypes calendarType)
        {
            System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
            int twoDigitYear;
            int expectedFourDigitYear, actualFourDigitYear;

            twoDigitYear          = c_MIN_TWO_DIGIT_YEAR;
            expectedFourDigitYear = GetExpectedFourDigitYear(myCalendar, twoDigitYear);
            actualFourDigitYear   = myCalendar.ToFourDigitYear(twoDigitYear);
            Assert.Equal(expectedFourDigitYear, actualFourDigitYear);
        }
예제 #23
0
        public void TwoDigitYearMax(GregorianCalendarTypes calendarType)
        {
            Calendar calendar = new GregorianCalendar(calendarType);

            Assert.True(calendar.TwoDigitYearMax == 2029 || calendar.TwoDigitYearMax == 2049, $"Unexpected calendar.TwoDigitYearMax {calendar.TwoDigitYearMax}");

            int randomTwoDigitYearMax = MinTwoDigitYear + s_randomDataGenerator.GetInt32(-55) % (MaxYear - MinTwoDigitYear + 1);

            calendar.TwoDigitYearMax = randomTwoDigitYearMax;
            Assert.Equal(randomTwoDigitYearMax, calendar.TwoDigitYearMax);
        }
        private void NegTest1(GregorianCalendarTypes calendarType)
        {
            System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
            int twoDigitYear;

            twoDigitYear = -1 * _generator.GetInt32(-55);
            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                myCalendar.ToFourDigitYear(twoDigitYear);
            });
        }
예제 #25
0
 public GregorianCalendar(GregorianCalendarTypes type)
 {
     if ((int)type < (int)GregorianCalendarTypes.Localized || (int)type > (int)GregorianCalendarTypes.TransliteratedFrench)
     {
         throw new ArgumentOutOfRangeException(
                   nameof(type),
                   SR.Format(SR.ArgumentOutOfRange_Range,
                             GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
     }
     this.m_type = type;
 }
        private static int GetExpectedFourDigitYear(GregorianCalendarTypes calendarType, int twoDigitYear)
        {
            GregorianCalendar calendar = new GregorianCalendar(calendarType);
            int expectedFourDigitYear  = calendar.TwoDigitYearMax - calendar.TwoDigitYearMax % 100 + twoDigitYear;

            if (expectedFourDigitYear > calendar.TwoDigitYearMax)
            {
                expectedFourDigitYear -= 100;
            }
            return(expectedFourDigitYear);
        }
        private void NegTest2(GregorianCalendarTypes calendarType)
        {
            System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
            int twoDigitYear;

            twoDigitYear = c_MAX_TWO_DIGIT_YEAR + _generator.GetInt32(-55) % (int.MaxValue - c_MAX_TWO_DIGIT_YEAR);
            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                myCalendar.ToFourDigitYear(twoDigitYear);
            });
        }
예제 #28
0
 public GregorianCalendar(GregorianCalendarTypes type)
 {
     if ((int)type < (int)GregorianCalendarTypes.Localized || (int)type > (int)GregorianCalendarTypes.TransliteratedFrench)
     {
         throw new ArgumentOutOfRangeException(
                   "type",
                   String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"),
                                 GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
     }
     this.m_type = type;
 }
        public void TwoDigitYearMax(GregorianCalendarTypes calendarType)
        {
            Calendar calendar = new GregorianCalendar(calendarType);

            Assert.Equal(DefaultTwoDigitMax, calendar.TwoDigitYearMax);

            int randomTwoDigitYearMax = MinTwoDigitYear + s_randomDataGenerator.GetInt32(-55) % (MaxYear - MinTwoDigitYear + 1);

            calendar.TwoDigitYearMax = randomTwoDigitYearMax;
            Assert.Equal(randomTwoDigitYearMax, calendar.TwoDigitYearMax);
        }
예제 #30
0
        private void PosTest1(GregorianCalendarTypes calendarType)
        {
            System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
            int twoDigitYear;
            int expectedFourDigitYear, actualFourDigitYear;

            twoDigitYear          = _generator.GetInt32(-55) % (c_MAX_TWO_DIGIT_YEAR + 1);
            expectedFourDigitYear = GetExpectedFourDigitYear(myCalendar, twoDigitYear);
            actualFourDigitYear   = myCalendar.ToFourDigitYear(twoDigitYear);
            Assert.Equal(expectedFourDigitYear, actualFourDigitYear);
        }
예제 #31
0
 public GregorianCalendar(GregorianCalendarTypes type)
 {
     if ((int)type < (int)GregorianCalendarTypes.Localized || (int)type > (int)GregorianCalendarTypes.TransliteratedFrench)
     {
         throw new ArgumentOutOfRangeException(
                   "type",
                   SR.Format(SR.ArgumentOutOfRange_Range,
                             GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
     }
     Contract.EndContractBlock();
     this.m_type = type;
 }
 public GregorianCalendar(GregorianCalendarTypes type)
 {
     if ((int)type < (int)GregorianCalendarTypes.Localized || (int)type > (int)GregorianCalendarTypes.TransliteratedFrench)
     {
         throw new ArgumentOutOfRangeException(
                   nameof(type),
                   Environment.GetResourceString("ArgumentOutOfRange_Range",
                                                 GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
     }
     Contract.EndContractBlock();
     this.m_type = type;
 }
        private void OnDeserialized(StreamingContext ctx)
        {
#if MONO
            // Mono version of CultureInfo used to serialize invariant calendar as 0 type
            if (m_type == 0)
                m_type = GregorianCalendarTypes.Localized;
#endif
            if (m_type < GregorianCalendarTypes.Localized || 
                m_type > GregorianCalendarTypes.TransliteratedFrench) 
            {
                throw new SerializationException(
                            String.Format(
                                CultureInfo.CurrentCulture, 
                                Environment.GetResourceString(
                                                "Serialization_MemberOutOfRange"),
                                                "type", 
                                                "GregorianCalendar"));
            }
        }
예제 #34
0
        public void GetCalendars()
        {
            Calendar[] myOptCals = new CultureInfo("en-US").OptionalCalendars;
            var        Calendar  = new GregorianCalendar(GregorianCalendarTypes.USEnglish);

            // Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
            Debug.WriteLine("The en-US culture supports the following calendars:");
            foreach (Calendar cal in myOptCals)
            {
                if (cal.GetType() == typeof(GregorianCalendar))
                {
                    GregorianCalendar      myGreCal = (GregorianCalendar)cal;
                    GregorianCalendarTypes calType  = myGreCal.CalendarType;
                    Debug.WriteLine("   {0} ({1})", cal, calType);
                }
                else
                {
                    Debug.WriteLine("   {0} {1}", cal, cal.AlgorithmType);
                }
            }
        }
예제 #35
0
        private void OnDeserialized(StreamingContext ctx)
        {
#if MONO
            // Mono version of CultureInfo used to serialize invariant calendar as 0 type
            if (m_type == 0)
            {
                m_type = GregorianCalendarTypes.Localized;
            }
#endif
            if (m_type < GregorianCalendarTypes.Localized ||
                m_type > GregorianCalendarTypes.TransliteratedFrench)
            {
                throw new SerializationException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              Environment.GetResourceString(
                                  "Serialization_MemberOutOfRange"),
                              "type",
                              "GregorianCalendar"));
            }
        }
예제 #36
0
    public static void Main()
    {
        // Gets the calendars supported by the ar-SA culture.
        Calendar[] myOptCals = new CultureInfo("ar-SA").OptionalCalendars;

        // Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
        Console.WriteLine("The ar-SA culture supports the following calendars:");
        foreach (Calendar cal in myOptCals)
        {
            if (cal.GetType() == typeof(GregorianCalendar))
            {
                GregorianCalendar      myGreCal = (GregorianCalendar)cal;
                GregorianCalendarTypes calType  = myGreCal.CalendarType;
                Console.WriteLine("   {0} ({1})", cal, calType);
            }
            else
            {
                Console.WriteLine("   {0}", cal);
            }
        }
    }
예제 #37
0
        internal unsafe void ConstructCalendars()
        {
            if (this.calendar_data == null)
            {
                this.optional_calendars = new Calendar[]
                {
                    new GregorianCalendar(GregorianCalendarTypes.Localized)
                };
                return;
            }
            this.optional_calendars = new Calendar[5];
            for (int i = 0; i < 5; i++)
            {
                int      num = this.calendar_data[i];
                Calendar calendar;
                switch (num >> 24)
                {
                case 0:
                {
                    GregorianCalendarTypes type = (GregorianCalendarTypes)(num & 16777215);
                    calendar = new GregorianCalendar(type);
                    break;
                }

                case 1:
                    calendar = new HijriCalendar();
                    break;

                case 2:
                    calendar = new ThaiBuddhistCalendar();
                    break;

                default:
                    throw new Exception("invalid calendar type:  " + num);
                }
                this.optional_calendars[i] = calendar;
            }
        }
        public static IEnumerable<object[]> ToFourDigitYear_TestData()
        {
            GregorianCalendarTypes[] calendarTypes = new GregorianCalendarTypes[]
            {
                GregorianCalendarTypes.Arabic,
                GregorianCalendarTypes.Localized,
                GregorianCalendarTypes.MiddleEastFrench,
                GregorianCalendarTypes.TransliteratedEnglish,
                GregorianCalendarTypes.TransliteratedFrench,
                GregorianCalendarTypes.USEnglish
            };

            foreach (GregorianCalendarTypes calendarType in calendarTypes)
            {
                // 0-99
                yield return new object[] { calendarType, s_randomDataGenerator.GetInt32(-55) % (MaxTwoDigitYear + 1) };

                // Min two digit year
                yield return new object[] { calendarType, MinTwoDigitYear };

                // Max two digit year
                yield return new object[] { calendarType, MaxTwoDigitYear };
            }
        }
예제 #39
0
 public void Ctor_GregorianCalendarTypes_InvalidType_ThrowsArgumentOutOfRangeException(GregorianCalendarTypes type)
 {
     Assert.Throws<ArgumentOutOfRangeException>("type", () => new GregorianCalendar(type));
 }
 public GregorianCalendar(GregorianCalendarTypes type);
예제 #41
0
 public GregorianCalendar(GregorianCalendarTypes type)
 {
     if ((int)type < (int)GregorianCalendarTypes.Localized || (int)type > (int)GregorianCalendarTypes.TransliteratedFrench)
     {
         throw new ArgumentOutOfRangeException(
                     nameof(type),
                     SR.Format(SR.ArgumentOutOfRange_Range,
             GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
     }
     Contract.EndContractBlock();
     this.m_type = type;
 }
예제 #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GregorianFiscalCalendar"/> class.
 /// </summary>
 /// <param name="epochMonth">The first month (1-12) in the calendar.</param>
 /// <param name="calendarType">One of the <see cref="GregorianCalendarTypes"/> values.</param>
 public GregorianFiscalCalendar( int epochMonth, GregorianCalendarTypes calendarType )
     : base( calendarType )
 {
     Arg.InRange( epochMonth, 1, 12, "epochMonth" );
     this.epochMonth = epochMonth;
 }
예제 #43
0
 public GregorianCalendar(GregorianCalendarTypes type) {
     if ((int)type < (int)GregorianCalendarTypes.Localized || (int)type > (int)GregorianCalendarTypes.TransliteratedFrench) {
         throw new ArgumentOutOfRangeException(
                     "type",
                     Environment.GetResourceString("ArgumentOutOfRange_Range",
             GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
     }
     Contract.EndContractBlock();
     this.m_type = type;
 }
	// Constructors.
	public GregorianCalendar()
			{
				calendarType = GregorianCalendarTypes.Localized;
			}
 private void NegTest2(GregorianCalendarTypes calendarType)
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
     int twoDigitYear;
     twoDigitYear = c_MAX_TWO_DIGIT_YEAR + TestLibrary.Generator.GetInt32(-55) % (int.MaxValue - c_MAX_TWO_DIGIT_YEAR);
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         myCalendar.ToFourDigitYear(twoDigitYear);
     });
 }
예제 #46
0
 public void Eras(GregorianCalendarTypes calendarType)
 {
     Calendar calendar = new GregorianCalendar(calendarType);
     Assert.Equal(new int[] { 1 }, calendar.Eras);
 }
예제 #47
0
		public GregorianCalendar(GregorianCalendarTypes type) {
			base.eraNames = new string[] { "A.D." };
			base.eraAbbrNames = new string[] { "AD" };
			this.type = type;
		}
예제 #48
0
 public GregorianCalendar(GregorianCalendarTypes type)
 {
     mEraNames = new string[] { "A.D." };
     mEraAbbrNames = new string[] { "AD" };
     mType = type;
 }
예제 #49
0
        public void CalendarType_SetInvalidValue_ThrowsArgumentOutOfRangeException(GregorianCalendarTypes type)
        {
            GregorianCalendar calendar = ((GregorianCalendar)Calendar);

            AssertExtensions.Throws <ArgumentOutOfRangeException>("value", "m_type", () => calendar.CalendarType = type);
        }
예제 #50
0
	/// <summary>
	/// Constructor that sets the
	/// Gregorian calendar type (
	/// <see cref="T:System.Globalization.GregorianCalendarTypes"/>).
	/// </summary>
	/// <param name="type">The parameter specifies the Gregorian 
	/// calendar type.
	/// </param>
	public GregorianCalendar(GregorianCalendarTypes type) {
		CalendarType = type;
		M_AbbrEraNames = new string[] {"AD"};
		M_EraNames = new string[] {"A.D."};
		if (twoDigitYearMax == 99)
			twoDigitYearMax = 2029;
	}
 public void MinSupportedDateTime(GregorianCalendarTypes calendarType)
 {
     Calendar calendar = new GregorianCalendar(calendarType);
     Assert.Equal(DateTime.MinValue, calendar.MinSupportedDateTime);
 }
예제 #52
0
 public void CalendarType_Set_InvalidType_ThrowsArgumentOutOfRangeException(GregorianCalendarTypes type)
 {
     GregorianCalendar calendar = new GregorianCalendar();
     Assert.Throws<ArgumentOutOfRangeException>("m_type", () => calendar.CalendarType = type);
 }
 private void NegTest1(GregorianCalendarTypes calendarType)
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
     int twoDigitYear;
     twoDigitYear = -1 * TestLibrary.Generator.GetInt32(-55);
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         myCalendar.ToFourDigitYear(twoDigitYear);
     });
 }
예제 #54
0
        public void MinSupportedDateTime(GregorianCalendarTypes calendarType)
        {
            Calendar calendar = new GregorianCalendar(calendarType);

            Assert.Equal(DateTime.MaxValue, calendar.MaxSupportedDateTime);
        }
	public GregorianCalendar(GregorianCalendarTypes type)
			{
				calendarType = type;
			}
예제 #56
0
 public void Ctor_GregorianCalendarType(GregorianCalendarTypes type)
 {
     GregorianCalendar calendar = new GregorianCalendar(type);
     Assert.Equal(type, calendar.CalendarType);
     Assert.False(calendar.IsReadOnly);
 }
예제 #57
0
        public void Eras(GregorianCalendarTypes calendarType)
        {
            Calendar calendar = new GregorianCalendar(calendarType);

            Assert.Equal(new int[] { 1 }, calendar.Eras);
        }
예제 #58
0
 public void CalendarType_Set(GregorianCalendarTypes type)
 {
     GregorianCalendar calendar = new GregorianCalendar();
     calendar.CalendarType = type;
     Assert.Equal(type, calendar.CalendarType);
 }
예제 #59
0
 /// <include file='doc\GregorianCalendar.uex' path='docs/doc[@for="GregorianCalendar.GregorianCalendar1"]/*' />
 public GregorianCalendar(GregorianCalendarTypes type) {
     this.m_type = type;
 }
 private void ToFourDigitYear(GregorianCalendarTypes calendarType, int year)
 {
     Calendar calendar = new GregorianCalendar(calendarType);
     int expected = GetExpectedFourDigitYear(calendar, year);
     Assert.Equal(expected, calendar.ToFourDigitYear(year));
 }