コード例 #1
0
ファイル: CopticTest.cs プロジェクト: bdqnghi/j2cstranslator
        public void TestYear()
        {
            // Gregorian Calendar
            IBM.ICU.Util.Calendar gCal = new IBM.ICU.Util.GregorianCalendar();
            DateTime gToday = gCal.GetTime();
            gCal.Add(IBM.ICU.Util.Calendar.MONTH, 2);
            DateTime gFuture = gCal.GetTime();
            DateFormat gDF = IBM.ICU.Text.DateFormat.GetDateInstance(gCal, IBM.ICU.Text.DateFormat.FULL);
            Logln("gregorian calendar: " + gDF.Format(gToday) + " + 2 months = "
                    + gDF.Format(gFuture));

            // Coptic Calendar
            CopticCalendar cCal = new CopticCalendar();
            DateTime cToday = cCal.GetTime();
            cCal.Add(IBM.ICU.Util.Calendar.MONTH, 2);
            DateTime cFuture = cCal.GetTime();
            DateFormat cDF = IBM.ICU.Text.DateFormat.GetDateInstance(cCal, IBM.ICU.Text.DateFormat.FULL);
            Logln("coptic calendar: " + cDF.Format(cToday) + " + 2 months = "
                    + cDF.Format(cFuture));

            // EthiopicCalendar
            EthiopicCalendar eCal = new EthiopicCalendar();
            DateTime eToday = eCal.GetTime();
            eCal.Add(IBM.ICU.Util.Calendar.MONTH, 2); // add 2 months
            eCal.SetAmeteAlemEra(false);
            DateTime eFuture = eCal.GetTime();
            DateFormat eDF = IBM.ICU.Text.DateFormat.GetDateInstance(eCal, IBM.ICU.Text.DateFormat.FULL);
            Logln("ethiopic calendar: " + eDF.Format(eToday) + " + 2 months = "
                    + eDF.Format(eFuture));
        }
コード例 #2
0
ファイル: CopticTest.cs プロジェクト: bdqnghi/j2cstranslator
 public void TestEraStart()
 {
     CopticCalendar cal = new CopticCalendar(0, 0, 1);
     IBM.ICU.Text.SimpleDateFormat fmt = new IBM.ICU.Text.SimpleDateFormat("EEE MMM dd, yyyy GG");
     AssertEquals("Coptic Date", "Thu Jan 01, 0000 AD", fmt.FormatObject(cal));
     AssertEquals("Gregorian Date", "Thu Aug 30, 0283 AD",
             fmt.Format(cal.GetTime()));
 }
コード例 #3
0
ファイル: CopticTest.cs プロジェクト: bdqnghi/j2cstranslator
 public void TestLimits()
 {
     IBM.ICU.Util.Calendar cal = IBM.ICU.Util.Calendar.GetInstance();
     cal.Set(2007, IBM.ICU.Util.Calendar.JANUARY, 1);
     CopticCalendar coptic = new CopticCalendar();
     if (!SkipIfBeforeICU(3, 9, 0))
     {
         DoLimitsTest(coptic, null, cal.GetTime());
     }
     DoTheoreticalLimitsTest(coptic, true);
 }
コード例 #4
0
ファイル: CopticTest.cs プロジェクト: bdqnghi/j2cstranslator
 public void TestBasic()
 {
     CopticCalendar cal = new CopticCalendar();
     cal.Clear();
     cal.Set(1000, 0, 30);
     Logln("1000/0/30-> " + cal.Get(IBM.ICU.Charset.CalendarTest.YEAR) + "/" + cal.Get(IBM.ICU.Charset.CalendarTest.MONTH) + "/"
             + cal.Get(IBM.ICU.Charset.CalendarTest.DATE));
     cal.Clear();
     cal.Set(1, 0, 30);
     Logln("1/0/30 -> " + cal.Get(IBM.ICU.Charset.CalendarTest.YEAR) + "/" + cal.Get(IBM.ICU.Charset.CalendarTest.MONTH) + "/"
             + cal.Get(IBM.ICU.Charset.CalendarTest.DATE));
 }
コード例 #5
0
ファイル: CopticTest.cs プロジェクト: bdqnghi/j2cstranslator
        public void TestCoverage()
        {

            {
                // new CopticCalendar(TimeZone)
                CopticCalendar cal = new CopticCalendar(IBM.ICU.Util.TimeZone.GetDefault());
                if (cal == null)
                {
                    Errln("could not create CopticCalendar with TimeZone");
                }
            }

            {
                // new CopticCalendar(ULocale)
                CopticCalendar cal_0 = new CopticCalendar(IBM.ICU.Util.ULocale.GetDefault());
                if (cal_0 == null)
                {
                    Errln("could not create CopticCalendar with ULocale");
                }
            }

            {
                // new CopticCalendar(Locale)
                CopticCalendar cal_1 = new CopticCalendar(ILOG.J2CsMapping.Util.Locale.GetDefault());
                if (cal_1 == null)
                {
                    Errln("could not create CopticCalendar with Locale");
                }
            }

            {
                // new CopticCalendar(TimeZone, Locale)
                CopticCalendar cal_2 = new CopticCalendar(IBM.ICU.Util.TimeZone.GetDefault(),
                        ILOG.J2CsMapping.Util.Locale.GetDefault());
                if (cal_2 == null)
                {
                    Errln("could not create CopticCalendar with TimeZone, Locale");
                }
            }

            {
                // new CopticCalendar(TimeZone, ULocale)
                CopticCalendar cal_3 = new CopticCalendar(IBM.ICU.Util.TimeZone.GetDefault(),
                        IBM.ICU.Util.ULocale.GetDefault());
                if (cal_3 == null)
                {
                    Errln("could not create CopticCalendar with TimeZone, ULocale");
                }
            }

            {
                // new CopticCalendar(Date)
                CopticCalendar cal_4 = new CopticCalendar(DateTime.Now);
                if (cal_4 == null)
                {
                    Errln("could not create CopticCalendar with Date");
                }
            }

            {
                // new CopticCalendar(int year, int month, int date)
                CopticCalendar cal_5 = new CopticCalendar(1997, IBM.ICU.Util.CopticCalendar.TOUT,
                        1);
                if (cal_5 == null)
                {
                    Errln("could not create CopticCalendar with year,month,date");
                }
            }

            {
                // new CopticCalendar(int year, int month, int date, int hour, int
                // minute, int second)
                CopticCalendar cal_6 = new CopticCalendar(1997, IBM.ICU.Util.CopticCalendar.TOUT,
                        1, 1, 1, 1);
                if (cal_6 == null)
                {
                    Errln("could not create CopticCalendar with year,month,date,hour,minute,second");
                }
            }

            {
                // data
                CopticCalendar cal_7 = new CopticCalendar(1997, IBM.ICU.Util.CopticCalendar.TOUT,
                        1);
                DateTime time = cal_7.GetTime();

                String[] calendarLocales = { "am_ET", "gez_ET", "ti_ET" };

                String[] formatLocales = { "en", "am", "am_ET", "gez", "ti" };
                for (int i = 0; i < calendarLocales.Length; ++i)
                {
                    String calLocName = calendarLocales[i];
                    ILOG.J2CsMapping.Util.Locale calLocale = IBM.ICU.Impl.LocaleUtility.GetLocaleFromName(calLocName);
                    cal_7 = new CopticCalendar(calLocale);

                    for (int j = 0; j < formatLocales.Length; ++j)
                    {
                        String locName = formatLocales[j];
                        ILOG.J2CsMapping.Util.Locale formatLocale = IBM.ICU.Impl.LocaleUtility
                                .GetLocaleFromName(locName);
                        DateFormat format = IBM.ICU.Text.DateFormat.GetDateTimeInstance(cal_7,
                                IBM.ICU.Text.DateFormat.FULL, IBM.ICU.Text.DateFormat.FULL, formatLocale);
                        Logln(calLocName + "/" + locName + " --> "
                                + format.Format(time));
                    }
                }
            }
        }
コード例 #6
0
ファイル: CopticTest.cs プロジェクト: bdqnghi/j2cstranslator
        /*
         * Test dates from: "The Amharic Letters of Emperor Theodore of Ethiopia to
         * Queen Victoria and Her Special Envoy", David Appleyard, Girma Selasse
         * Asfaw, Oxford University Press, June 1 1979, ISBN: 0856726605, Longwood
         * Pr Ltd
         * 
         * Coptic Gregorian JD 20/02/1579 29/10/1862 2401443 29/10/1581 05/07/1865
         * 2402423 22/05/1582 29/01/1866 2402631 10/08/1582 17/04/1866 2402709
         * 28/04/1583 05/01/1867 2402972 05/05/1584 13/01/1868 2403345
         * 
         * --------------------------------------------------
         * 
         * From the Calendrica applet:
         * http://emr.cs.iit.edu/home/reingold/calendar-book/Calendrica.html
         * 
         * Coptic Gregorian JD 07/05/-284 01/01/0000 1721060 08/05/-283 01/01/0001
         * 1721426 06/13/-1 29/08/0283 1824664
         * 
         * 01/01/0000 30/08/0283 1824665 01/01/0001 29/08/0284 1825030 01/01/0002
         * 29/08/0285 1825395 01/01/0003 29/08/0286 1825760 01/01/0004 30/08/0287
         * 1826126 05/13/0000 28/08/0284 1825029 05/13/0001 28/08/0285 1825394
         * 05/13/0002 28/08/0286 1825759 05/13/0003 28/08/0287 1826124 06/13/0003
         * 29/08/0287 1826125 first coptic leap year 05/13/0004 28/08/0288 1826490
         * 
         * 06/02/1299 13/10/1582 2299159 07/02/1299 14/10/1582 2299160 Julian
         * 04/10/1582 08/02/1299 15/10/1582 2299161 09/02/1299 16/10/1582 2299162
         * 
         * 23/04/1616 01/01/1900 2415021 23/04/1721 01/01/2005 2453372 05/13/2000
         * 12/09/2284 2555529
         */

        /// <summary>
        /// A huge list of test cases to make sure that computeTime and computeFields
        /// work properly for a wide range of data in the civil calendar.
        /// </summary>
        ///
        public void TestCases()
        {
            TestCase[] tests = {
                    //
                    // The months in this table are 1-based rather than 0-based,
                    // because it's easier to edit that way.
                    // Coptic
                    // Julian Day Era Year Month Day WkDay Hour Min Sec
                    //
                    // Dates from "Emporer Theodore..."
	
                    new TestCase(2401442.5d, 1, 1579, 2, 20, IBM.ICU.Charset.CalendarTest.WED, 0, 0, 0), // Gregorian:
                                                                           // 20/10/1862
                    new TestCase(2402422.5d, 1, 1581, 10, 29, IBM.ICU.Charset.CalendarTest.WED, 0, 0, 0), // Gregorian:
                                                                            // 05/07/1865
                    new TestCase(2402630.5d, 1, 1582, 5, 22, IBM.ICU.Charset.CalendarTest.MON, 0, 0, 0), // Gregorian:
                                                                           // 29/01/1866
                    new TestCase(2402708.5d, 1, 1582, 8, 10, IBM.ICU.Charset.CalendarTest.TUE, 0, 0, 0), // Gregorian:
                                                                           // 17/04/1866
                    new TestCase(2402971.5d, 1, 1583, 4, 28, IBM.ICU.Charset.CalendarTest.SAT, 0, 0, 0), // Gregorian:
                                                                           // 05/01/1867
                    new TestCase(2403344.5d, 1, 1584, 5, 5, IBM.ICU.Charset.CalendarTest.MON, 0, 0, 0), // Gregorian:
                                                                          // 13/01/1868
                    new TestCase(1721059.5d, 0, -284, 5, 7, IBM.ICU.Charset.CalendarTest.SAT, 0, 0, 0), // Gregorian:
                                                                          // 01/01/0000
                    new TestCase(1721425.5d, 0, -283, 5, 8, IBM.ICU.Charset.CalendarTest.MON, 0, 0, 0), // Gregorian:
                                                                          // 01/01/0001
                    new TestCase(1824663.5d, 0, -1, 13, 6, IBM.ICU.Charset.CalendarTest.WED, 0, 0, 0), // Gregorian:
                                                                         // 29/08/0283
                    new TestCase(1824664.5d, 1, 0, 1, 1, IBM.ICU.Charset.CalendarTest.THU, 0, 0, 0), // Gregorian:
                                                                       // 30/08/0283
                    new TestCase(1825029.5d, 1, 1, 1, 1, IBM.ICU.Charset.CalendarTest.FRI, 0, 0, 0), // Gregorian:
                                                                       // 29/08/0284
                    new TestCase(1825394.5d, 1, 2, 1, 1, IBM.ICU.Charset.CalendarTest.SAT, 0, 0, 0), // Gregorian:
                                                                       // 29/08/0285
                    new TestCase(1825759.5d, 1, 3, 1, 1, IBM.ICU.Charset.CalendarTest.SUN, 0, 0, 0), // Gregorian:
                                                                       // 29/08/0286
                    new TestCase(1826125.5d, 1, 4, 1, 1, IBM.ICU.Charset.CalendarTest.TUE, 0, 0, 0), // Gregorian:
                                                                       // 30/08/0287
                    new TestCase(1825028.5d, 1, 0, 13, 5, IBM.ICU.Charset.CalendarTest.THU, 0, 0, 0), // Gregorian:
                                                                        // 28/08/0284
                    new TestCase(1825393.5d, 1, 1, 13, 5, IBM.ICU.Charset.CalendarTest.FRI, 0, 0, 0), // Gregorian:
                                                                        // 28/08/0285
                    new TestCase(1825758.5d, 1, 2, 13, 5, IBM.ICU.Charset.CalendarTest.SAT, 0, 0, 0), // Gregorian:
                                                                        // 28/08/0286
                    new TestCase(1826123.5d, 1, 3, 13, 5, IBM.ICU.Charset.CalendarTest.SUN, 0, 0, 0), // Gregorian:
                                                                        // 28/08/0287
                    new TestCase(1826124.5d, 1, 3, 13, 6, IBM.ICU.Charset.CalendarTest.MON, 0, 0, 0), // Gregorian:
                                                                        // 29/08/0287
                    // above is first coptic leap year
                    new TestCase(1826489.5d, 1, 4, 13, 5, IBM.ICU.Charset.CalendarTest.TUE, 0, 0, 0), // Gregorian:
                                                                        // 28/08/0288
                    new TestCase(2299158.5d, 1, 1299, 2, 6, IBM.ICU.Charset.CalendarTest.WED, 0, 0, 0), // Gregorian:
                                                                          // 13/10/1582
                    new TestCase(2299159.5d, 1, 1299, 2, 7, IBM.ICU.Charset.CalendarTest.THU, 0, 0, 0), // Gregorian:
                                                                          // 14/10/1582
	
                    new TestCase(2299160.5d, 1, 1299, 2, 8, IBM.ICU.Charset.CalendarTest.FRI, 0, 0, 0), // Gregorian:
                                                                          // 15/10/1582
                    new TestCase(2299161.5d, 1, 1299, 2, 9, IBM.ICU.Charset.CalendarTest.SAT, 0, 0, 0), // Gregorian:
                                                                          // 16/10/1582
	
                    new TestCase(2415020.5d, 1, 1616, 4, 23, IBM.ICU.Charset.CalendarTest.MON, 0, 0, 0), // Gregorian:
                                                                           // 01/01/1900
                    new TestCase(2453371.5d, 1, 1721, 4, 23, IBM.ICU.Charset.CalendarTest.SAT, 0, 0, 0), // Gregorian:
                                                                           // 01/01/2005
                    new TestCase(2555528.5d, 1, 2000, 13, 5, IBM.ICU.Charset.CalendarTest.FRI, 0, 0, 0), // Gregorian:
                                                                           // 12/09/2284
            };

            CopticCalendar testCalendar = new CopticCalendar();
            testCalendar.SetLenient(true);
            DoTestCases(tests, testCalendar);
        }