Home > atmlab > time > weeksinyear.m

weeksinyear

PURPOSE ^

WEEKSINYEAR Number of weeks in a year.

SYNOPSIS ^

function n = weeksinyear(year)

DESCRIPTION ^

WEEKSINYEAR Number of weeks in a year.

   WEEKSINYEAR(YEAR) returns the number of weeks in the given year.

   The number of weeks is always either 52 or 53.

   If no year is specified, the current year is used.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

weeksinyear.m

SOURCE CODE ^

0001 function n = weeksinyear(year)
0002 %WEEKSINYEAR Number of weeks in a year.
0003 %
0004 %   WEEKSINYEAR(YEAR) returns the number of weeks in the given year.
0005 %
0006 %   The number of weeks is always either 52 or 53.
0007 %
0008 %   If no year is specified, the current year is used.
0009 
0010 %   Author:      Peter J. Acklam
0011 %   Time-stamp:  2002-03-03 12:49:04 +0100
0012 %   E-mail:      pjacklam@online.no
0013 %   URL:         http://home.online.no/~pjacklam
0014 
0015    if nargin < 1
0016       clk = clock;
0017       year = clk(1);
0018    end
0019 
0020    n = ( 365 + isleapyear(year) ...
0021          + dayofweek(year, 1, 4) - dayofweek(year+1, 1, 4) )/7;

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005