Anyone know an easy way to get the date of the first day in the week (monday here in Europe). I know the year and the week number? I'm going to do this in C#.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
I have written and tested the following code and is working perfectly fine for me. Please let me know if anyone face trouble with this, I have posted a question as well in order to get the best possible answer. Someone may find it useful.
Lightly changed Mikael Svenson code. I found the week of the first monday and appropriate change the week number.
I simplified the code Mikael Svensson provided which is correct for many countries in Europe.
According to ISO 8601:1988 that is used in Sweden the first week of the year is the first week that has at least four days within the new year.
So if your week starts on a Monday the first Thursday any year is within the first week. You can DateAdd or DateDiff from that.
using Fluent DateTime http://fluentdatetime.codeplex.com/
I improved a little on Thomas' solution with an override:
Otherwise the date was preceding by one week..
Thank you Thomas, great help.