예제 #1
0
        private void ResultButton_Click(object sender, RoutedEventArgs e)
        {
            DateSunTextBlock.Text = CustomDisplayDate(DemoDatePicker.Date.DateTime);
            DateTime  d  = DemoDatePicker.Date.DateTime;
            LunarDate ld = d.ToLunarDate();

            DateMoonTextBlock.Text = ld.ToString();
        }
        private void ResultButton_Click(object sender, RoutedEventArgs e)
        {
            DateMoonTextBlock.Text = CustomDisplayDate(DemoDatePicker.Date.DateTime);
            //DateTime d = DemoDatePicker.Date.DateTime;
            LunarDate ld = new LunarDate(DemoDatePicker.Date.Day, DemoDatePicker.Date.Month, DemoDatePicker.Date.Year, false);
            DateTime  d  = ld.ToSolarDate();

            DateSunTextBlock.Text = d.ToString();
        }
        public static DateTime LunarToSolar(LunarDate ld, int timeZone)
        {
            long k, a11, b11, off, leapOff, leapMonth, monthStart;

            if (ld.Month < 11)
            {
                a11 = LunarYearTools.getLunarMonth11(ld.Year - 1, timeZone);
                b11 = LunarYearTools.getLunarMonth11(ld.Year, timeZone);
            }
            else
            {
                a11 = LunarYearTools.getLunarMonth11(ld.Year, timeZone);
                b11 = LunarYearTools.getLunarMonth11(ld.Year + 1, timeZone);
            }
            k   = LunarYearTools.INT(0.5 + (a11 - 2415021.076998695) / 29.530588853);
            off = ld.Month - 11;
            if (off < 0)
            {
                off += 12;
            }
            if (b11 - a11 > 365)
            {
                leapOff   = LunarYearTools.getLeapMonthOffset(a11, timeZone);
                leapMonth = leapOff - 2;
                if (leapMonth < 0)
                {
                    leapMonth += 12;
                }
                if (ld.IsLeapYear && ld.Month != leapMonth)
                {
                    return(DateTime.MinValue);
                }
                else if (ld.IsLeapYear || off >= leapOff)
                {
                    off += 1;
                }
            }
            monthStart = LunarYearTools.getNewMoonDay(k + off, timeZone);
            return(LunarYearTools.jdToDate(monthStart + ld.Day - 1));
        }
 private void ResultButton_Click(object sender, RoutedEventArgs e)
 {
     DateMoonTextBlock.Text = CustomDisplayDate(DemoDatePicker.Date.DateTime);
     //DateTime d = DemoDatePicker.Date.DateTime;
     LunarDate ld = new LunarDate(DemoDatePicker.Date.Day, DemoDatePicker.Date.Month, DemoDatePicker.Date.Year, false);
     DateTime d = ld.ToSolarDate();
     DateSunTextBlock.Text = d.ToString();
 }
 /* Convert a lunar date to the corresponding solar date */
 public static DateTime LunarToSolar(LunarDate ld)
 {
     return(LunarToSolar(ld, 7));
 }
 public static DateTime LunarToSolar(LunarDate ld, int timeZone)
 {
     long k, a11, b11, off, leapOff, leapMonth, monthStart;
     if (ld.Month < 11)
     {
         a11 = LunarYearTools.getLunarMonth11(ld.Year - 1, timeZone);
         b11 = LunarYearTools.getLunarMonth11(ld.Year, timeZone);
     }
     else
     {
         a11 = LunarYearTools.getLunarMonth11(ld.Year, timeZone);
         b11 = LunarYearTools.getLunarMonth11(ld.Year + 1, timeZone);
     }
     k = LunarYearTools.INT(0.5 + (a11 - 2415021.076998695) / 29.530588853);
     off = ld.Month - 11;
     if (off < 0)
     {
         off += 12;
     }
     if (b11 - a11 > 365)
     {
         leapOff = LunarYearTools.getLeapMonthOffset(a11, timeZone);
         leapMonth = leapOff - 2;
         if (leapMonth < 0)
         {
             leapMonth += 12;
         }
         if (ld.IsLeapYear && ld.Month != leapMonth)
         {
             return DateTime.MinValue;
         }
         else if (ld.IsLeapYear || off >= leapOff)
         {
             off += 1;
         }
     }
     monthStart = LunarYearTools.getNewMoonDay(k + off, timeZone);
     return LunarYearTools.jdToDate(monthStart + ld.Day - 1);
 }
 /* Convert a lunar date to the corresponding solar date */
 public static DateTime LunarToSolar(LunarDate ld)
 {
     return LunarToSolar(ld, 7);
 }