开发者

How do I get the first day in a week Week, Year (gregorian calendar) in C#?

开发者 https://www.devze.com 2022-12-13 09:41 出处:网络
I need to calculate the date of the first day in a calendar week given a year/week, e.g. Week 53 in 2009 -> Mon, 28.12.2009

I need to calculate the date of the first day in a calendar week given a year/week, e.g.

Week 53 in 2009 -> Mon, 28.12.2009

开发者_运维技巧Week 1 in 2010 -> Mon, 04.01.2010

How would you wirte that code?

PS: In the Gregorian calendar the first week of a year is the first week with 4 days.


If you don't want to do all the calculation yourself, use the System.Globalization.Calendar class. I think you can use the GetDayOfYear() method to get what you need.

Check this MSDN library for the example.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号