RFH> One of my CS professors always insisted: "Do not reinvent the wheel -
RFH> If something works, just COPY it".
RFH> With that in mind, where can I find an algorithm/snippet that
RFH> converts:
RFH> date --> week number
Read "man strftime" on nearest Unix-like system. This function supports a
few week number definitions according to different practice styles:
===
%U is replaced by the week number of the year (Sunday as the first day
of the week) as a decimal number (00-53).
%V is replaced by the week number of the year (Monday as the first day
of the week) as a decimal number (01-53). If the week containing
January 1 has four or more days in the new year, then it is week 1;
otherwise it is the last week of the previous year, and the next
week is week 1.
%W is replaced by the week number of the year (Monday as the first day
of the week) as a decimal number (00-53).
===
Its sources can be got from any open source Unix clone.
RFH> and its inverse:
RFH> week number --> date range
RFH> Just to make sure:
RFH> The year has 52 weeks, and their week numbers are: week 1, week 2,
RFH> week 3, etc.
This definition is incorrect: any year (supposing traditional
Gregorian calendar) has 52 full weeks and 1 partial, so if you start
with 1, Dec, 31 will always belong to week 53.
See above how to define week number in more useful way.
RFH> I believe that today (9/3/2009) we are in week number 36 of the year.
OK, but you should not be sure three days later.;)))
--netch--