Search code examples
c#vb.netdatetime.net-2.0

Week count issue using the TimePeriod library (CodeProject)


I am just trying to make use of this TimePeriod library. I just found something which I'm not sure is correct, yet I'm not able to flag it as a bug. Just need a clarification.

Dim xDateDiff As New DateDiff(New Date(2011, 1, 1), New Date(2011, 2, 1))
Console.WriteLine("Week Count : " + xDateDiff.Weeks().ToString()

Now the week count is outputting 5, where as there are, if you see the Gregorian calendar, 6 weeks between the two dates. Is the week count zero-based? This is what is troubling me.

Please help.


Solution

  • I never used the TimePeriod library, but isn't it just that there is a 5-week difference between two dates, but there are 6 weeks if you include the first week? My point is, couldn't you just do xDateDiff.Weeks() + 1?