monthCalendar

时间:2017-11-10 03:58:02
【文件属性】:

文件名称:monthCalendar

文件大小:881B

文件格式:SLN

更新时间:2017-11-10 03:58:02

万年历

制作一个简易的万年历 string intmonth = monthCalendar1.TodayDate.Month.ToString(); string intday = monthCalendar1.TodayDate.Day.ToString(); if (monthCalendar1.TodayDate.Month < 10) { intmonth = "0" + monthCalendar1.TodayDate.Month.ToString(); } if (monthCalendar1.TodayDate.Day < 10) { intday = "0" + monthCalendar1.TodayDate.Day.ToString(); } string s = String.Format("{0}年{1}月{2}", GetStemBranch(monthCalendar1.TodayDate), GetMonth(monthCalendar1.TodayDate), GetDay(monthCalendar1.TodayDate)); label1.Text = monthCalendar1.TodayDate + "年" + intmonth + "月" + intday + "日" + " " + s + " " + getReturnYear(monthCalendar1.TodayDate)+"年"; label1.ForeColor = Color.Green; } public string GetStemBranch(DateTime time) { string TerrestrialBranch = "子丑寅卯辰巳午未申酉戌亥"; string CelestialStem = "甲乙丙丁戊己庚辛壬癸"; int sexagenaryYear = cc.GetSexagenaryYear(time);//计算与指定日期对应的甲子(60年)循环中的年,此方法返回甲子循环中的一个从1到60的数字,它与date参数对应 string stemBranch = CelestialStem.Substring(cc.GetCelestialStem(sexagenaryYear) - 1, 1) + TerrestrialBranch.Substring(cc.GetTerrestrialBranch(sexagenaryYear) - 1, 1);//substring() 方法返回的子串包括 start 处的字符,但不包括 stop 处的字符 return stemBranch; } public string GetMonth(DateTime time) { string[] ChineseMonthName = new string[] { "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二" }; int month =cc.GetMonth(time);//获取当前日期的月份 int year = cc.GetYear(time);//获取当前日期的年份 int leap = 0; for (int i = 3; i <= month; i++) { if (cc.IsLeapMonth(year,i))//判断是否是闰年 { leap = i;//一年中最多有一个闰月 break; } } if (leap > 0) month--; return (leap == month + 1 ? "闰" : "") +ChineseMonthName[month - 1];//返回农历月份


网友评论

  • 骗子啊 还要一个积分