public static List<PatternInfo> GetYearMonthList(int type = 1)
{
List<PatternInfo> rList = new List<PatternInfo>();
DateTime curTime = DateTime.Now.AddMonths((type == 1 ? -1 : 0));
rList.Add(new PatternInfo()
{
PatternCode = "-1",
PatternName = "--请选择--"
});
int cYear = curTime.Year;
int cMonth = curTime.Month;
for (int i = 0; i <= 10; i++)
{
for (int j = cMonth; j > 0; j--)
{
PatternInfo _curMonthInfo = new PatternInfo();
_curMonthInfo.PatternCode = string.Format("{0}{1}", cYear, (j < 10 ? "0" + j.ToString() : j.ToString()));
_curMonthInfo.PatternName = string.Format("{0}{1}", cYear, (j < 10 ? "0" + j.ToString() : j.ToString()));
rList.Add(_curMonthInfo);
}
cYear--;
cMonth = 12;
}
return rList;
}
public static List<PatternInfo> GetYearQuarterList(int
c#生成年,年月,年月日,季度,周类型日期。
最新推荐文章于 2024-01-11 09:38:07 发布
这篇博客介绍了如何使用C#生成不同类型的日期,包括年份、年月、年月日、季度和周。通过GetYearMonthList、GetYearQuarterList、GetYearDayList、GetYearWeekList和GetYBookYearList等方法,可以获取过去和未来的日期组合,方便在日期选择场景中使用。
摘要由CSDN通过智能技术生成