Esempio n. 1
0
        public void TestElulMonth()
        {
            try
            {
                IBM.ICU.Util.HebrewCalendar cal = new IBM.ICU.Util.HebrewCalendar();
                // Leap years are:
                // 3 6 8 11 14 17 19 (and so on - 19-year cycle)
                for (int year = 1; year < 50; year++)
                {
                    // I hope that year = 0 does not exists
                    // because the test fails for it !
                    cal.Clear();

                    cal.Set(IBM.ICU.Util.Calendar.YEAR, year);
                    cal.Set(IBM.ICU.Util.Calendar.MONTH, ELUL);
                    cal.Set(IBM.ICU.Util.Calendar.DAY_OF_MONTH, 1);

                    int yact = cal.Get(IBM.ICU.Util.Calendar.YEAR);
                    int mact = cal.Get(IBM.ICU.Util.Calendar.MONTH);

                    if (year != yact || ELUL != mact)
                    {
                        Errln("Fail: " + ELUL + "/" + year + " -> " + mact + "/"
                              + yact);
                    }
                }
            }
            catch (MissingManifestResourceException ex)
            {
                Warnln("Got Exception: " + ex.Message);
            }
        }
Esempio n. 2
0
 public void TestLimits()
 {
     IBM.ICU.Util.Calendar cal = IBM.ICU.Util.Calendar.GetInstance();
     cal.Set(2007, IBM.ICU.Util.Calendar.JANUARY, 1);
     IBM.ICU.Util.HebrewCalendar hebrew = new IBM.ICU.Util.HebrewCalendar();
     DoLimitsTest(hebrew, null, cal.GetTime());
     DoTheoreticalLimitsTest(hebrew, true);
 }
Esempio n. 3
0
 public void TestDefaultFieldValues()
 {
     try
     {
         IBM.ICU.Util.HebrewCalendar cal = new IBM.ICU.Util.HebrewCalendar();
         cal.Clear();
         Logln("cal.clear() -> " + cal.GetTime());
     }
     catch (MissingManifestResourceException ex)
     {
         Warnln("could not load the locale data");
     }
 }
Esempio n. 4
0
 public void TestTimeFields()
 {
     try
     {
         IBM.ICU.Util.HebrewCalendar calendar = new IBM.ICU.Util.HebrewCalendar(5761, 0, 11, 12, 28,
                                                                                15);
         calendar.Set(IBM.ICU.Util.Calendar.YEAR, 5717);
         calendar.Set(IBM.ICU.Util.Calendar.MONTH, 2);
         calendar.Set(IBM.ICU.Util.Calendar.DAY_OF_MONTH, 23);
         if (calendar.Get(IBM.ICU.Util.Calendar.HOUR_OF_DAY) != 12)
         {
             Errln("Fail: HebrewCalendar HOUR_OF_DAY = "
                   + calendar.Get(IBM.ICU.Util.Calendar.HOUR_OF_DAY));
         }
     }
     catch (MissingManifestResourceException ex)
     {
         Warnln("Got Exception: " + ex.Message);
     }
 }
Esempio n. 5
0
        public void TestRoll()
        {
            int[][] tests = new int[][] {
                new int[] {
                    5759,
                    HESHVAN,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    1, 5759, KISLEV, 2
                },
                new int[] {
                    5759,
                    SHEVAT,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    1, 5759, ADAR, 2
                },
                new int[] {
                    5759,
                    SHEVAT,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    2, 5759, NISAN, 2
                },
                new int[] {
                    5759,
                    SHEVAT,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    12, 5759, SHEVAT, 2
                },
                new int[] {
                    5759,
                    AV,
                    1,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    12, 5759, AV, 1
                },
                new int[] {
                    5757,
                    HESHVAN,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    1, 5757, KISLEV, 2
                },
                new int[] {
                    5757,
                    SHEVAT,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    1, 5757, ADAR_1, 2
                },
                new int[] {
                    5757,
                    SHEVAT,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    2, 5757, ADAR, 2
                },
                new int[] {
                    5757,
                    SHEVAT,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    3, 5757, NISAN, 2
                },
                new int[] {
                    5757,
                    SHEVAT,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    12, 5757, TEVET, 2
                },
                new int[] {
                    5757,
                    SHEVAT,
                    2,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    13, 5757, SHEVAT, 2
                },
                new int[] {
                    5757,
                    AV,
                    1,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    12, 5757, TAMUZ, 1
                },
                new int[] {
                    5757,
                    KISLEV,
                    1,
                    IBM.ICU.Charset.CalendarTest.DATE,
                    30, 5757, KISLEV, 2
                },
                new int[] {
                    5758,
                    KISLEV,
                    1,
                    IBM.ICU.Charset.CalendarTest.DATE,
                    31, 5758, KISLEV, 2
                },
                new int[] {
                    5757,
                    TISHRI,
                    1,
                    IBM.ICU.Charset.CalendarTest.YEAR,
                    1, 5758, TISHRI, 1
                },
                new int[] {
                    5757,
                    TISHRI,
                    30,
                    IBM.ICU.Charset.CalendarTest.MONTH,
                    1, 5757, HESHVAN, 29
                },
                new int[] {
                    5758,
                    KISLEV,
                    30,
                    IBM.ICU.Charset.CalendarTest.YEAR,
                    -1, 5757, KISLEV, 29
                }
            };
            // try{
            IBM.ICU.Util.HebrewCalendar cal = new IBM.ICU.Util.HebrewCalendar(IBM.ICU.Charset.CalendarTest.UTC, ILOG.J2CsMapping.Util.Locale.GetDefault());

            DoRollAdd(IBM.ICU.Charset.CalendarTest.ROLL, cal, tests);
            // }catch(MissingResourceException ex){
            // warnln("Got Exception: "+ ex.getMessage());
            // }
        }
Esempio n. 6
0
        public void TestCoverage()
        {
            try
            {
                {
                    // new HebrewCalendar(TimeZone)
                    IBM.ICU.Util.HebrewCalendar cal = new IBM.ICU.Util.HebrewCalendar(IBM.ICU.Util.TimeZone.GetDefault());
                    if (cal == null)
                    {
                        Errln("could not create HebrewCalendar with TimeZone");
                    }
                }

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

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

                {
                    // new HebrewCalendar(Date)
                    IBM.ICU.Util.HebrewCalendar cal_2 = new IBM.ICU.Util.HebrewCalendar(DateTime.Now);
                    if (cal_2 == null)
                    {
                        Errln("could not create HebrewCalendar with date");
                    }
                }

                {
                    // data
                    IBM.ICU.Util.HebrewCalendar cal_3 = new IBM.ICU.Util.HebrewCalendar(2800,
                                                                                        IBM.ICU.Util.HebrewCalendar.SHEVAT, 1);
                    DateTime time = cal_3.GetTime();

                    String[] calendarLocales = { "iw_IL" };

                    String[] formatLocales = { "en", "fi", "fr", "hu", "iw", "nl" };
                    for (int i = 0; i < calendarLocales.Length; ++i)
                    {
                        String calLocName = calendarLocales[i];
                        ILOG.J2CsMapping.Util.Locale calLocale = IBM.ICU.Impl.LocaleUtility
                                                                 .GetLocaleFromName(calLocName);
                        cal_3 = new IBM.ICU.Util.HebrewCalendar(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_3,
                                                                                            IBM.ICU.Text.DateFormat.FULL, IBM.ICU.Text.DateFormat.FULL, formatLocale);
                            Logln(calLocName + "/" + locName + " --> "
                                  + format.Format(time));
                        }
                    }
                }
            }
            catch (MissingManifestResourceException ex)
            {
                Warnln("Could not load the locale data. " + ex.Message);
            }
        }
Esempio n. 7
0
        public void TestMonthMovement()
        {
            try
            {
                IBM.ICU.Util.HebrewCalendar cal = new IBM.ICU.Util.HebrewCalendar();
                // Leap years are:
                // 3 6 8 11 14 17 19 (and so on - 19-year cycle)
                // We can't test complete() on some lines below because of ADAR_1 --
                // if
                // the calendar is set to ADAR_1 on a non-leap year, the result is
                // undefined.
                int[] DATA =
                {
                    // m1/y1 - month/year before (month is 1-based)
                    // delta - amount to add to month field
                    // m2/y2 - month/year after add(MONTH, delta)
                    // m3/y3 - month/year after set(MONTH, m1+delta)
                    // m1 y1 delta m2 y2 m3 y3
                    10,  2, +24, 9,  4, 9,  4, 10, 2, +60, 8, 7, 8, 7, 1, 2, +12,
                    1,   3,  13,
                    2,                         // *set != add; also see '*' below
                    3,  18, -24, 4, 16, 4, 16,  1, 6, -24, 1, 4, 1, 4, 4, 3,  +2,
                    6,   3,   6, 3,            // Leap year - no skip 4,5,6,7,8
                    8,   3,  -2, 6,  3, 6,  3, // Leap year - no skip
                    4,   2,  +2, 7,  2, 7,  2, // Skip leap month 4,5,(6),7,8
                    8,   2,  -2, 5,  2, 7,  2, // *Skip leap month going backward
                };
                for (int i = 0; i < DATA.Length;)
                {
                    int m = DATA[i++], y = DATA[i++];
                    int monthDelta = DATA[i++];
                    int m2 = DATA[i++], y2 = DATA[i++];
                    int m3 = DATA[i++], y3 = DATA[i++];
                    int mact, yact;

                    cal.Clear();
                    cal.Set(IBM.ICU.Util.Calendar.YEAR, y);
                    cal.Set(IBM.ICU.Util.Calendar.MONTH, m - 1);
                    cal.Add(IBM.ICU.Util.Calendar.MONTH, monthDelta);
                    yact = cal.Get(IBM.ICU.Util.Calendar.YEAR);
                    mact = cal.Get(IBM.ICU.Util.Calendar.MONTH) + 1;
                    if (y2 != yact || m2 != mact)
                    {
                        Errln("Fail: " + m + "/" + y + " -> add(MONTH, "
                              + monthDelta + ") -> " + mact + "/" + yact
                              + ", expected " + m2 + "/" + y2);
                        cal.Clear();
                        cal.Set(IBM.ICU.Util.Calendar.YEAR, y);
                        cal.Set(IBM.ICU.Util.Calendar.MONTH, m - 1);
                        Logln("Start: " + m + "/" + y);
                        int delta = (monthDelta > 0) ? 1 : -1;
                        for (int c = 0; c != monthDelta; c += delta)
                        {
                            cal.Add(IBM.ICU.Util.Calendar.MONTH, delta);
                            Logln("+ " + delta + " MONTH -> "
                                  + (cal.Get(IBM.ICU.Util.Calendar.MONTH) + 1) + "/"
                                  + cal.Get(IBM.ICU.Util.Calendar.YEAR));
                        }
                    }

                    cal.Clear();
                    cal.Set(IBM.ICU.Util.Calendar.YEAR, y);
                    cal.Set(IBM.ICU.Util.Calendar.MONTH, m + monthDelta - 1);
                    yact = cal.Get(IBM.ICU.Util.Calendar.YEAR);
                    mact = cal.Get(IBM.ICU.Util.Calendar.MONTH) + 1;
                    if (y3 != yact || m3 != mact)
                    {
                        Errln("Fail: " + (m + monthDelta) + "/" + y
                              + " -> complete() -> " + mact + "/" + yact
                              + ", expected " + m3 + "/" + y3);
                    }
                }
            }
            catch (MissingManifestResourceException ex)
            {
                Warnln("Got Exception: " + ex.Message);
            }
        }
Esempio n. 8
0
        public void TestAdd()
        {
            int[][] tests = new int[][] {
                new int[] { 5759, HESHVAN, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 1,
                            5759, KISLEV, 2 },
                new int[] { 5759, SHEVAT, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 1,
                            5759, ADAR, 2 },
                new int[] { 5759, SHEVAT, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 2,
                            5759, NISAN, 2 },
                new int[] { 5759, SHEVAT, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 12,
                            5760, SHEVAT, 2 },
                new int[] { 5757, HESHVAN, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 1,
                            5757, KISLEV, 2 },
                new int[] { 5757, SHEVAT, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 1,
                            5757, ADAR_1, 2 },
                new int[] { 5757, SHEVAT, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 2,
                            5757, ADAR, 2 },
                new int[] { 5757, SHEVAT, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 3,
                            5757, NISAN, 2 },
                new int[] { 5757, SHEVAT, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 12,
                            5758, TEVET, 2 },
                new int[] { 5757, SHEVAT, 2,
                            IBM.ICU.Charset.CalendarTest.MONTH, 13,
                            5758, SHEVAT, 2 },
                new int[] { 5762, AV, 1,
                            IBM.ICU.Charset.CalendarTest.MONTH, 1,
                            5762, ELUL, 1 },
                new int[] { 5762, AV, 30,
                            IBM.ICU.Charset.CalendarTest.DATE, 1,
                            5762, ELUL, 1 },
                new int[] { 5762, ELUL, 1,
                            IBM.ICU.Charset.CalendarTest.DATE, -1,
                            5762, AV, 30 },
                new int[] { 5762, ELUL, 1,
                            IBM.ICU.Charset.CalendarTest.MONTH, -1,
                            5762, AV, 1 },
                new int[] { 5757, KISLEV, 1,
                            IBM.ICU.Charset.CalendarTest.DATE, 30,
                            5757, TEVET, 2 },
                new int[] { 5758, KISLEV, 1,
                            IBM.ICU.Charset.CalendarTest.DATE, 31,
                            5758, TEVET, 2 }
            };
            try
            {
                IBM.ICU.Util.HebrewCalendar cal = new IBM.ICU.Util.HebrewCalendar(IBM.ICU.Charset.CalendarTest.UTC, ILOG.J2CsMapping.Util.Locale.GetDefault());

                DoRollAdd(IBM.ICU.Charset.CalendarTest.ADD, cal, tests);
            }
            catch (MissingManifestResourceException ex)
            {
                Warnln("Could not load the locale data");
            }
        }