private static IslamicCalendar NewCivil() { IslamicCalendar civilCalendar = new IslamicCalendar(); civilCalendar.SetCivil(true); return(civilCalendar); }
public void TestCoverage() { { // new IslamicCalendar(TimeZone) IslamicCalendar cal = new IslamicCalendar(IBM.ICU.Util.TimeZone.GetDefault()); if (cal == null) { Errln("could not create IslamicCalendar with TimeZone"); } } { // new IslamicCalendar(ULocale) IslamicCalendar cal_0 = new IslamicCalendar(IBM.ICU.Util.ULocale.GetDefault()); if (cal_0 == null) { Errln("could not create IslamicCalendar with ULocale"); } } { // new IslamicCalendar(Locale) IslamicCalendar cal_1 = new IslamicCalendar(ILOG.J2CsMapping.Util.Locale.GetDefault()); if (cal_1 == null) { Errln("could not create IslamicCalendar with Locale"); } } { // new IslamicCalendar(Date) IslamicCalendar cal_2 = new IslamicCalendar(DateTime.Now); if (cal_2 == null) { Errln("could not create IslamicCalendar with Date"); } } { // new IslamicCalendar(int year, int month, int date) IslamicCalendar cal_3 = new IslamicCalendar(800, IBM.ICU.Util.IslamicCalendar.RAMADAN, 1); if (cal_3 == null) { Errln("could not create IslamicCalendar with year,month,date"); } } { // new IslamicCalendar(int year, int month, int date, int hour, int // minute, int second) IslamicCalendar cal_4 = new IslamicCalendar(800, IBM.ICU.Util.IslamicCalendar.RAMADAN, 1, 1, 1, 1); if (cal_4 == null) { Errln("could not create IslamicCalendar with year,month,date,hour,minute,second"); } } { // setCivil/isCivil // operations on non-civil calendar IslamicCalendar cal_5 = new IslamicCalendar(800, IBM.ICU.Util.IslamicCalendar.RAMADAN, 1, 1, 1, 1); cal_5.SetCivil(false); if (cal_5.IsCivil()) { Errln("islamic calendar is civil"); } DateTime now = DateTime.Now; cal_5.SetTime(now); DateTime then = cal_5.GetTime(); if (!now.Equals(then)) { Errln("get/set time failed with non-civil islamic calendar"); } Logln(then.ToString()); cal_5.Add(IBM.ICU.Util.Calendar.MONTH, 1); cal_5.Add(IBM.ICU.Util.Calendar.DAY_OF_MONTH, 1); cal_5.Add(IBM.ICU.Util.Calendar.YEAR, 1); Logln(cal_5.GetTime().ToString()); } { // data IslamicCalendar cal_6 = new IslamicCalendar(800, IBM.ICU.Util.IslamicCalendar.RAMADAN, 1); DateTime time = cal_6.GetTime(); String[] calendarLocales = { "ar_AE", "ar_BH", "ar_DZ", "ar_EG", "ar_JO", "ar_KW", "ar_OM", "ar_QA","ar_SA", "ar_SY", "ar_YE", "ms_MY" }; String[] formatLocales = { "en", "ar", "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_6 = new IslamicCalendar(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_6, IBM.ICU.Text.DateFormat.FULL, IBM.ICU.Text.DateFormat.FULL, formatLocale); Logln(calLocName + "/" + locName + " --> " + format.Format(time)); } } } }