Ejemplo n.º 1
0
        private void qtc_DateSelected(object sender, DateRangeEventArgs e)
        {
            lvDates.BeginUpdate();
            try
            {
                string s;

                lvDates.Items.Clear();

                DateTime gdt = qtc.SelectionStart;
                double   jd  = CalendarConverter.gregorian_to_jd(gdt.Year, gdt.Month, gdt.Day);

                var dtx = CalendarConverter.jd_to_gregorian(jd);
                s = d2s(dtx.Day, CalendarData.ClassicMonths[dtx.Month - 1], dtx.Year, CalendarData.ClassicWeekdays[CalendarConverter.jwday(jd)]);
                AddItem(fPlugin.LangMan.LS(PLS.LSID_Cal_Gregorian), s);

                dtx = CalendarConverter.jd_to_julian(jd);
                s   = d2s(dtx.Day, CalendarData.ClassicMonths[dtx.Month - 1], dtx.Year, CalendarData.ClassicWeekdays[CalendarConverter.jwday(jd)]);
                AddItem(fPlugin.LangMan.LS(PLS.LSID_Cal_Julian), s);

                dtx = CalendarConverter.jd_to_hebrew(jd);
                s   = d2s(dtx.Day, CalendarData.HebrewMonths[dtx.Month - 1], dtx.Year, CalendarData.HebrewWeekdays[CalendarConverter.jwday(jd)]);
                AddItem(fPlugin.LangMan.LS(PLS.LSID_Cal_Hebrew), s);

                dtx = CalendarConverter.jd_to_islamic(jd);
                s   = d2s(dtx.Day, CalendarData.IslamicMonths[dtx.Month - 1], dtx.Year, CalendarData.IslamicWeekdays[CalendarConverter.jwday(jd)]);
                AddItem(fPlugin.LangMan.LS(PLS.LSID_Cal_Islamic), s);

                dtx = CalendarConverter.jd_to_persian(jd);
                s   = d2s(dtx.Day, CalendarData.PersianMonths[dtx.Month - 1], dtx.Year, CalendarData.PersianWeekdays[CalendarConverter.jwday(jd)]);
                AddItem(fPlugin.LangMan.LS(PLS.LSID_Cal_Persian), s);

                dtx = CalendarConverter.jd_to_indian_civil(jd);
                s   = d2s(dtx.Day, CalendarData.IndianCivilMonths[dtx.Month - 1], dtx.Year, CalendarData.IndianCivilWeekdays[CalendarConverter.jwday(jd)]);
                AddItem(fPlugin.LangMan.LS(PLS.LSID_Cal_Indian), s);

                dtx = CalendarConverter.jd_to_bahai(jd);
                s   = string.Format(fPlugin.LangMan.LS(PLS.LSID_BahaiCycles), dtx.BahaiMajor, dtx.BahaiCycle) + ", ";
                s   = s + d2s(dtx.Day, CalendarData.BahaiMonths[dtx.Month - 1], dtx.Year, CalendarData.BahaiWeekdays[CalendarConverter.jwday(jd)]);
                AddItem(fPlugin.LangMan.LS(PLS.LSID_Cal_Bahai), s);
            }
            finally
            {
                lvDates.EndUpdate();
            }
        }
Ejemplo n.º 2
0
        public void Test_Common()
        {
            DateTime gdt = new DateTime(1990, 10, 10);
            string   s;

            double jd = CalendarConverter.gregorian_to_jd2(gdt.Year, gdt.Month, gdt.Day);

            Assert.AreEqual(2448175, jd); //

            jd = CalendarConverter.gregorian_to_jd2(-4713, 11, 24);
            Assert.AreEqual(0.0, jd); //


            jd = CalendarConverter.gregorian_to_jd(-4713, 11, 24);
            Assert.AreEqual(0.5, jd); // bad result! needs 0.0f!

            jd = CalendarConverter.gregorian_to_jd(gdt.Year, gdt.Month, gdt.Day);
            Assert.AreEqual(2448174.5, jd); // not checked!


            var dtx = CalendarConverter.jd_to_julian(jd);

            s = d2s(dtx.Day, CalendarData.ClassicMonths[dtx.Month - 1], dtx.Year, "");
            Assert.AreEqual("27 September 1990, ", s); // +

            dtx = CalendarConverter.jd_to_hebrew(jd);
            s   = d2s(dtx.Day, CalendarData.HebrewMonths[dtx.Month - 1], dtx.Year, CalendarData.HebrewWeekdays[CalendarConverter.jwday(jd)]);
            Assert.AreEqual("21 Tishri 5751, Dalet", s); // +

            dtx = CalendarConverter.jd_to_islamic(jd);
            s   = d2s(dtx.Day, CalendarData.IslamicMonths[dtx.Month - 1], dtx.Year, CalendarData.IslamicWeekdays[CalendarConverter.jwday(jd)]);
            Assert.AreEqual("20 Rabi`al-Awwal 1411, Al-'arb`a'", s); // +

            dtx = CalendarConverter.jd_to_persian(jd);
            s   = d2s(dtx.Day, CalendarData.PersianMonths[dtx.Month - 1], dtx.Year, CalendarData.PersianWeekdays[CalendarConverter.jwday(jd)]);
            Assert.AreEqual("18 Mehr 1369, Chaharshanbeh", s); // +

            dtx = CalendarConverter.jd_to_indian_civil(jd);
            s   = d2s(dtx.Day, CalendarData.IndianCivilMonths[dtx.Month - 1], dtx.Year, CalendarData.IndianCivilWeekdays[CalendarConverter.jwday(jd)]);
            Assert.AreEqual("18 Asvina 1912, Budhavara", s); // +

            dtx = CalendarConverter.jd_to_bahai(jd);
            s   = "major " + dtx.BahaiMajor.ToString() + ", cycle " + dtx.BahaiCycle.ToString() + ", ";
            s   = s + d2s(dtx.Day, CalendarData.BahaiMonths[dtx.Month - 1], dtx.Year, CalendarData.BahaiWeekdays[CalendarConverter.jwday(jd)]);
            Assert.AreEqual("major 1, cycle 8, 14 Mashíyyat 14, ‘Idál", s); // ???
        }
Ejemplo n.º 3
0
        private void qtc_DateSelected(object sender, DateRangeEventArgs e)
        {
            lvDates.BeginUpdate();
            try
            {
                lvDates.Items.Clear();

                DateTime gdt = qtc.SelectionStart;
                double   jd  = CalendarConverter.gregorian_to_jd(gdt.Year, gdt.Month, gdt.Day);

                int year, month, day;

                CalendarConverter.jd_to_gregorian(jd, out year, out month, out day);
                AddCItem(jd, year, month, day, fClassicMonths, fClassicWeekdays, "", fPlugin.LangMan.LS(PLS.LSID_Cal_Gregorian));

                CalendarConverter.jd_to_julian(jd, out year, out month, out day);
                AddCItem(jd, year, month, day, fClassicMonths, fClassicWeekdays, "", fPlugin.LangMan.LS(PLS.LSID_Cal_Julian));

                CalendarConverter.jd_to_hebrew(jd, out year, out month, out day);
                AddCItem(jd, year, month, day, fHebrewMonths, fHebrewWeekdays, "", fPlugin.LangMan.LS(PLS.LSID_Cal_Hebrew));

                CalendarConverter.jd_to_islamic(jd, out year, out month, out day);
                AddCItem(jd, year, month, day, fIslamicMonths, fIslamicWeekdays, "", fPlugin.LangMan.LS(PLS.LSID_Cal_Islamic));

                CalendarConverter.jd_to_persian(jd, out year, out month, out day);
                AddCItem(jd, year, month, day, fPersianMonths, fPersianWeekdays, "", fPlugin.LangMan.LS(PLS.LSID_Cal_Persian));

                CalendarConverter.jd_to_indian_civil(jd, out year, out month, out day);
                AddCItem(jd, year, month, day, fIndianCivilMonths, fIndianCivilWeekdays, "", fPlugin.LangMan.LS(PLS.LSID_Cal_Indian));

                int major, cycle;
                CalendarConverter.jd_to_bahai(jd, out major, out cycle, out year, out month, out day);
                string s = string.Format(fPlugin.LangMan.LS(PLS.LSID_BahaiCycles), major, cycle) + ", ";
                AddCItem(jd, year, month, day, fBahaiMonths, fBahaiWeekdays, s, fPlugin.LangMan.LS(PLS.LSID_Cal_Bahai));
            }
            finally
            {
                lvDates.EndUpdate();
            }
        }