PDA

View Full Version : ISO week number



lsatenstein
12-27-2012, 08:29 PM
There is a closed thread about week number which does not provide the ISO or manufacturing week number. I would like to reopen the thread

The week number has January 4th somewhere between Monday
and Sunday.
Week one consists of part of last year where January 1 of the year is before the Thursday in the new year.

Example 1
SU MO TU WE TH FR SA SU
29 30 31 1 2 3 4 5 This is week 1 because JAN 4 is before SU

Example 2
SU MO TU WE TH FR SA SU
27 28 29 30 31 1 2 3 This could be week 52 or 53 depending
on the starting year and leap year.

I believe that the main function is one which for a date provides the week day number.
It is not to difficult to calculate the starting week 1,
but then you need to also check the cutoff for the last week in the year. Wikipaedia and ISO week number provides some good explanations, but no c or c++ code.

Salem
12-28-2012, 02:25 AM
An actual link to the closed thread would be useful.

strftime (http://pubs.opengroup.org/onlinepubs/7908799/xsh/strftime.html)
Does your implementation support the %V format?