コード例 #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 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));
                    }
                }
            }
        }