【发布时间】:2018-05-08 16:04:09
【问题描述】:
我想编写一个函数来获取一年中的周数,并返回该周的开始日期。还有另一个函数获取周数,并返回该周的结束日期。
伪代码:
public DateTime GetSaturdayDateOfWeek(int weekNumberInYear)
{
// calculations, that finds the Saturday of that week, 00:00:00 of midnight
return DateTime.Now;
}
public DateTime GetFriddayDateOfWeek(int weekNumberInYear)
{
// calculations, that finds the Friday of that week, 23:59:59
return DateTime.Now;
}
如何计算这些日期?
This question is in PHP 并没有帮助我。还有this question gets the week number of the month。我有一年中的周数。
【问题讨论】:
-
周的开始和结束是特定于文化的。此外,周数有些模糊 - 如果一周从星期一开始,而 1 月 1 日是星期四,那么 1 月 6 日(一年中的第一个星期二)属于一年中的第一周还是第二周?更不用说每年的开始日期都与前一年不同......
-
@ZoharPeled 回答这些问题的相关人员:stackoverflow.com/questions/5791919/…
标签: c#