perlfaq nodetype
faq_monk
<P>
The day of the year is in the array returned by
<CODE>localtime()</CODE> (see
<U>localtime</U>):
<P>
<PRE> $day_of_year = (localtime(time()))[7];
</PRE>
<P>
or more legibly (in 5.004 or higher):
<P>
<PRE> use Time::localtime;
$day_of_year = localtime(time())->yday;
</PRE>
<P>
You can find the week of the year by dividing this by 7:
<P>
<PRE> $week_of_year = int($day_of_year / 7);
</PRE>
<P>
Of course, this believes that weeks start at zero. The Date::Calc module from
<FONT SIZE=-1>CPAN</FONT> has a lot of date calculation functions, including day of the year, week of the year, and so on. Note that not all business consider ``week 1'' to be the same; for example, American business often consider the first week with a Monday in it to be Work Week #1, despite
<FONT SIZE=-1>ISO</FONT> 8601, which consider
<FONT SIZE=-1>WW1</FONT> to be the frist week with a Thursday in it.
<P>