Home > omviz > julian.m

julian

PURPOSE ^

JULIAN Converts Gregorian calendar dates to corresponding

SYNOPSIS ^

function [j]=julian(y,m,d,h)

DESCRIPTION ^

JULIAN  Converts Gregorian calendar dates to corresponding
      Julian day numbers.  Although the formal definition
      holds that Julian days start and end at noon, here
      Julian days start and end at midnight.

    In this convention, Julian day 2440000 began at 0000 hours, May 23, 1968.


     Usage: [j]=julian(y,m,d,h)  or  [j]=julian([y m d hour min sec])
     ************************************************************

        d.... day (1-31) component of Gregorian date
        m.... month (1-12) component
        y.... year (e.g., 1979) component
        j.... decimal Julian day number
        h.... decimal hours (assumed 0 if absent)

     ************************************************************
     recoded for MATLAB  by Rich Signell, 5-15-91

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [j]=julian(y,m,d,h)
0002 %JULIAN  Converts Gregorian calendar dates to corresponding
0003 %      Julian day numbers.  Although the formal definition
0004 %      holds that Julian days start and end at noon, here
0005 %      Julian days start and end at midnight.
0006 %
0007 %    In this convention, Julian day 2440000 began at 0000 hours, May 23, 1968.
0008 %
0009 %
0010 %     Usage: [j]=julian(y,m,d,h)  or  [j]=julian([y m d hour min sec])
0011 %     ************************************************************
0012 %
0013 %        d.... day (1-31) component of Gregorian date
0014 %        m.... month (1-12) component
0015 %        y.... year (e.g., 1979) component
0016 %        j.... decimal Julian day number
0017 %        h.... decimal hours (assumed 0 if absent)
0018 %
0019 %     ************************************************************
0020 %     recoded for MATLAB  by Rich Signell, 5-15-91
0021 %
0022       if nargin==3,
0023         h=0.;
0024       elseif nargin==1,
0025         h=hms2h(y(:,4),y(:,5),y(:,6));
0026         d=y(:,3);
0027         m=y(:,2);
0028         y=y(:,1);
0029       end
0030       mo=m+9;
0031       yr=y-1;
0032       i=(m>2);
0033       mo(i)=m(i)-3;
0034       yr(i)=y(i); 
0035       c = floor(yr/100);
0036       yr = yr - c*100;
0037       j = floor((146097*c)/4) + floor((1461*yr)/4) + ...
0038            floor((153*mo +2)/5) +d +1721119;
0039 
0040 %     If you want julian days to start and end at noon,
0041 %     replace the following line with:
0042 %     j=j+(h-12)/24;
0043  
0044       j=j+h/24;
0045

Generated on Thu 01-Dec-2005 08:50:35 by m2html © 2003