Home > atmlab > time > hms2days.m

hms2days

PURPOSE ^

HMS2DAYS Convert hours, minutes, and seconds to days.

SYNOPSIS ^

function days = hms2days(HOUR, MINUTE, SECOND)

DESCRIPTION ^

HMS2DAYS Convert hours, minutes, and seconds to days.

   DAYS = HMS2DAYS(HOUR, MINUTE, SECOND) converts the number of hours,
   minutes, and seconds to a number of days.

   The following holds (to within rounding precision):

     DAYS = HOUR / 24 + MINUTE / (24 * 60) + SECOND / (24 * 60 * 60)
          = (HOUR + (MINUTE + SECOND / 60) / 60) / 24

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

hms2days.m

SOURCE CODE ^

0001 function days = hms2days(HOUR, MINUTE, SECOND)
0002 %HMS2DAYS Convert hours, minutes, and seconds to days.
0003 %
0004 %   DAYS = HMS2DAYS(HOUR, MINUTE, SECOND) converts the number of hours,
0005 %   minutes, and seconds to a number of days.
0006 %
0007 %   The following holds (to within rounding precision):
0008 %
0009 %     DAYS = HOUR / 24 + MINUTE / (24 * 60) + SECOND / (24 * 60 * 60)
0010 %          = (HOUR + (MINUTE + SECOND / 60) / 60) / 24
0011 
0012 %   Author:      Peter J. Acklam
0013 %   Time-stamp:  2002-05-24 15:23:31 +0200
0014 %   E-mail:      pjacklam@online.no
0015 %   URL:         http://home.online.no/~pjacklam
0016 
0017    error(nargchk(1, 3, nargin));
0018    argv = {0 0 0};
0019    argv(1:nargsin) = varargin;
0020    [hour, minute, second] = deal(argv{:});
0021 
0022    days = (hour + (minute + second / 60) / 60) / 24;

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