Home > atmlab > time > yearnum.m

yearnum

PURPOSE ^

YEARNUM Ordinal year number.

SYNOPSIS ^

function y = yearnum(varargin)

DESCRIPTION ^

YEARNUM Ordinal year number.

   YEARNUM(YEAR, MONTH, DAY, HOUR, MIN, SEC) returns the ordinal year
   number plus a fractional part depending on the month, day, and time of
   day.

   Any missing MONTH or DAY will be replaced by ones.  Any missing HOUR,
   MINUTE or SECOND will be replaced by zeros.

   If no date is specified, the current date and time is used.  Gregorian
   calendar is assumed.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

yearnum.m

SOURCE CODE ^

0001 function y = yearnum(varargin)
0002 %YEARNUM Ordinal year number.
0003 %
0004 %   YEARNUM(YEAR, MONTH, DAY, HOUR, MIN, SEC) returns the ordinal year
0005 %   number plus a fractional part depending on the month, day, and time of
0006 %   day.
0007 %
0008 %   Any missing MONTH or DAY will be replaced by ones.  Any missing HOUR,
0009 %   MINUTE or SECOND will be replaced by zeros.
0010 %
0011 %   If no date is specified, the current date and time is used.  Gregorian
0012 %   calendar is assumed.
0013 
0014 %   Author:      Peter J. Acklam
0015 %   Time-stamp:  2002-03-03 12:49:10 +0100
0016 %   E-mail:      pjacklam@online.no
0017 %   URL:         http://home.online.no/~pjacklam
0018 
0019    nargsin = nargin;
0020    error(nargchk(0, 6, nargsin));
0021    if nargsin
0022       argv = {1 1 1 0 0 0};
0023       argv(1:nargsin) = varargin;
0024    else
0025       argv = num2cell(clock);
0026    end
0027    [year, month, day, hour, minute, second] = deal(argv{:});
0028 
0029    year + (dayofyear(year, month, day, hour, minute, second) - 1) ...
0030           ./ daysinyear(year);

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