/// 第n週の日付を取得する
/// </summary>
/// <param name="year">年</param>
/// <param name="month">月</param>
/// <param name="n">第n週</param>
/// <param name="dayOfWeek">曜日の指定</param>
/// <returns></returns>
private DateTime NthWDay(int year, int month, int n, DayOfWeek dayOfWeek) {
int fw = (int)(new DateTime(year, month, 1)).DayOfWeek;
int firstDay = ((int)dayOfWeek - fw) + 1;
if (firstDay <= 0)
firstDay += 7;
int day = firstDay + (n - 1) * 7;
return new DateTime(year, month, day);
}
0 件のコメント:
コメントを投稿