Date::WeekOfYear - Simple routine to return the week of the year (as well as the year)


  use Date::WeekOfYear;
  # Get the week number (and year for the end/start of year transitions)
  my ($wkNo, $year) = WeekOfYear();
  # Get the week number for the time passed in time_stamp
  my ($wkNo, $year) = WeekOfYear($time_stamp);
  # Use the data for someThing ...
  my $logFile = "/someDir/$year/someApp_$wkNo.log"
  # Only want the week number, don't care which year in the week around
  # the end/start of the year !
  my $weekNo = WeekOfYear();


Date::WeekOfYear is small and efficient. The only purpose is to return the week of the year. This can be called in either a scalar or list context.

In a scalar context, just the week number is returned (the year starts at week 1).

In a list context, both the week number and the year (YYYY) are returned. This ensures that you know which year the week number relates too. This is only an issue in the week where the year changes (ie depending on the day you can be in either week 52 or week 1.

Note there if you are after other date related functions then there are plenty of other Date::* modules on CPAN provide the functionality of this module in addition other ...



WeekOfYear. That's it, nice and simple


None, however please contact the author at should you find any problems and I will endevour to resolve then as soon as possible


 Greg George, IT Technology Solutions P/L, Australia
 Mobile: +61-404-892-159, Email:


Date::Parse or check CPAN


$Log:,v $ Revision 1.3 2009/06/20 09:31:39 Greg - Real tests with Test::More - Tests moved to t/ - Better Makefile.PL - Now WeekOfYear can take an argument (unixtime)

Revision 1.2 2006/06/11 02:28:55 Greg - Correction to name of function

Revision 2004/08/09 11:07:15 Greg - Initial release to CPAN


$Id:,v 1.3 2009/06/20 09:31:39 Greg Exp $