public static ArrayList GetMonths(int year, int timeZone) { ArrayList months = new ArrayList(); LunarDate lunarDate1 = new LunarDate(1, 1, false, year, timeZone); LunarDate newMoonDay = lunarDate1; SolarDate testDate_Solar; LunarDate testDate_Lunar; do { string month = newMoonDay.Month.ToString("00"); if (newMoonDay.IsLeapMonth) { month += " nhuận"; } months.Add(month); if (year == 9999 && month == "12") { break; } testDate_Solar = new SolarDate(newMoonDay.JulianDayNumber + 32); testDate_Lunar = testDate_Solar.ToLunarDate(timeZone); newMoonDay = new LunarDate(1, testDate_Lunar.Month, testDate_Lunar.isLeapMonth, year, timeZone); }while (testDate_Lunar.Year == year); return(months); }
private void cldLunarMonthCalendar_SelectedMonthChanged(object sender, EventArgs e) { currentMonth = cldLunarMonthCalendar.SelectedMonth.Month; currentYear = cldLunarMonthCalendar.SelectedMonth.Year; txtMonthCalendar_Year.Text = cldLunarMonthCalendar.SelectedMonth.Year.ToString("0000"); cmbMonthCalendar_Month.Text = cldLunarMonthCalendar.SelectedMonth.Month.ToString("00"); if (currentSolarYear == 1 && currentMonth == 1) { btnMonthCalendar_PreviousMonth.Enabled = false; } else { btnMonthCalendar_PreviousMonth.Enabled = true; } if (currentYear == 9999 && currentMonth == 12) { btnMonthCalendar_NextMonth.Enabled = false; } else { btnMonthCalendar_NextMonth.Enabled = true; } SolarDate sd = new SolarDate(cldLunarMonthCalendar.SelectedMonth); LunarDate ld = sd.ToLunarDate(timeZone); }
private void cldLunarDayCalendar_SelectedDateChanged(object sender, EventArgs e) { currentSolarYear = cldLunarDayCalendar.SelectedDate.Year; currentSolarMonth = cldLunarDayCalendar.SelectedDate.Month; currentSolarDay = cldLunarDayCalendar.SelectedDate.Day; SolarDate solarDate = new SolarDate(currentSolarDay, currentSolarMonth, currentSolarYear); LunarDate lunarDate = solarDate.ToLunarDate(timeZone); currentLunarYear = lunarDate.Year; currentLunarMonth = lunarDate.Month; currentLunarIsLeapMonth = lunarDate.IsLeapMonth; currentLunarDay = lunarDate.Day; DayCalendar_UpdateValue(); if (solarDate == SolarDate.MinValue) { btnDayCalendar_PreviousDate.Enabled = false; } else { btnDayCalendar_PreviousDate.Enabled = true; } if (solarDate == SolarDate.MaxValue) { btnDayCalendar_NextDate.Enabled = false; } else { btnDayCalendar_NextDate.Enabled = true; } }
private void cldLunarDayCalendar_SelectedDateChanged(object sender, EventArgs e) { currentSolarDate = new SolarDate(cldLunarDayCalendar.SelectedDate); currentLunarDate = currentSolarDate.ToLunarDate(timeZone); DayCalendar_UpdateValue(); if (currentSolarDate == SolarDate.MinValue) { btnDayCalendar_PreviousDate.Enabled = false; } else { btnDayCalendar_PreviousDate.Enabled = true; } if (currentSolarDate == SolarDate.MaxValue) { btnDayCalendar_NextDate.Enabled = false; } else { btnDayCalendar_NextDate.Enabled = true; } }
public Main() { InitializeComponent(); currentSolarDate = new SolarDate(DateTime.Today); currentLunarDate = currentSolarDate.ToLunarDate(timeZone); currentMonth = DateTime.Today.Month; currentYear = DateTime.Today.Year; DayCalendar_FillValue(); MonthCalendar_FillValue(); cldLunarDayCalendar.SelectedDate = DateTime.Today; cldLunarMonthCalendar.SelectedMonth = DateTime.Today; }
public static int GetNumberOfDaysInMonth(int month, bool isLeapMonth, int year, int timeZone) { if (year == 9999 && month == 12) { return(29); } LunarDate newMoonDay_Lunar = new LunarDate(1, month, isLeapMonth, year, timeZone); SolarDate newMoonDay_Solar = newMoonDay_Lunar.ToSolarDate(); SolarDate testDate_Solar = new SolarDate(newMoonDay_Solar.JulianDayNumber + 32); LunarDate testDate_Lunar = testDate_Solar.ToLunarDate(timeZone); LunarDate nextNewMoonDay_Lunar = new LunarDate(1, testDate_Lunar.Month, testDate_Lunar.isLeapMonth, testDate_Lunar.Year, timeZone); SolarDate nextNewMoonDay_Solar = nextNewMoonDay_Lunar.ToSolarDate(); return((int)(nextNewMoonDay_Solar.JulianDayNumber - newMoonDay_Solar.JulianDayNumber)); }
//Khởi tạo public frmMain() { InitializeComponent(); currentSolarYear = DateTime.Today.Year; currentSolarMonth = DateTime.Today.Month; currentSolarDay = DateTime.Today.Day; SolarDate today_Solar = new SolarDate(currentSolarDay, currentSolarMonth, currentSolarYear); LunarDate today_Lunar = today_Solar.ToLunarDate(timeZone); currentLunarYear = today_Lunar.Year; currentLunarMonth = today_Lunar.Month; currentLunarIsLeapMonth = today_Lunar.IsLeapMonth; currentLunarDay = today_Lunar.Day; DayCalendar_FillValue(); MonthCalendar_FillValue(); cldLunarDayCalendar.SelectedDate = DateTime.Today; cldLunarMonthCalendar.SelectedMonth = DateTime.Today; }