/// <summary>
/// 获取本日日期
/// (12月16日)
/// </summary>
/// <returns></returns>
public string[] GetToday()
{
List<string> list = new List<string>();
list.Add(now.ToString("MM月dd日"));
return list.ToArray();
}
/// <summary>
/// 获取本周第1天到今天的日期
/// (12月11日、12月12日...12月16日)
/// </summary>
/// <returns></returns>
public string[] GetWeekDay()
{
//星期天为第一天
int weeknow = Convert.ToInt32(now.DayOfWeek);
List<string> list = new List<string>();
for (int i = weeknow; i > 0; i--)
{
//因为是以星期一为第一天,所以要判断weeknow等于0时,要向前推6天。
weeknow = (weeknow == 0 ? (7 - 1) : (weeknow - 1));
int daydiff = (-1) * weeknow;
//本周第一天
string firstDay = now.AddDays(daydiff).ToString("MM月dd日");
list.Add(firstDay);
}
return list.ToArray();
}
/// <summary>
/// 获取本月第1日到今天的日期
/// (12月1日、12月2日、.....12月16日)
/// </summary>
/// <returns></returns>
public string[] GetMonthDay()
{
string month = new DateTime(now.Year, now.Month, 1).ToString("MM月dd日");
List<string> list = new List<string>();
for (int i = 1; i <= now.Day; i++)
{
string day = new DateTime(now.Year, now.Month, i).ToString("MM月dd日");
list.Add(day);
}
return list.ToArray();
}