


JULIAN: Converts Gregorian calendar dates to Julian dates.
USAGE: [j]=julian([y m d hour min sec]) or [j]=julian(y,m,d,h)
DESCRIPTION: Converts Gregorian dates to decimal Julian days using the
astronomical convension, but with time zero starting
at midnight instead of noon. In this convention,
Julian day 2440000 begins at 0000 hours, May 23, 1968.
The decimal Julian day, with Matlab's double precision,
yeilds an accuracy of decimal days of about 0.1 milliseconds.
INPUT:
y = year (e.g., 1979) component
m = month (1-12) component
d = day (1-31) component of Gregorian date
hour = hours (0-23)
min = minutes (0-59)
sec = decimal seconds
or
h = decimal hours (assumed 0 if absent)
OUTPUT:
j = decimal Julian day number

0001 function [j]=julian(y,m,d,h) 0002 0003 % JULIAN: Converts Gregorian calendar dates to Julian dates. 0004 % 0005 % USAGE: [j]=julian([y m d hour min sec]) or [j]=julian(y,m,d,h) 0006 % 0007 % DESCRIPTION: Converts Gregorian dates to decimal Julian days using the 0008 % astronomical convension, but with time zero starting 0009 % at midnight instead of noon. In this convention, 0010 % Julian day 2440000 begins at 0000 hours, May 23, 1968. 0011 % The decimal Julian day, with Matlab's double precision, 0012 % yeilds an accuracy of decimal days of about 0.1 milliseconds. 0013 % 0014 % INPUT: 0015 % y = year (e.g., 1979) component 0016 % m = month (1-12) component 0017 % d = day (1-31) component of Gregorian date 0018 % 0019 % hour = hours (0-23) 0020 % min = minutes (0-59) 0021 % sec = decimal seconds 0022 % or 0023 % h = decimal hours (assumed 0 if absent) 0024 % 0025 % OUTPUT: 0026 % j = decimal Julian day number 0027 0028 % last revised 1/3/96 by Rich Signell (rsignell@usgs.gov) 0029 0030 if nargin==3, 0031 h=0.; 0032 elseif nargin==1, 0033 [m,n]=size(y); 0034 if n==3, %assume h=m=s=0 if not supplied 0035 h=zeros(m,1); 0036 else 0037 h=hms2h(y(:,4),y(:,5),y(:,6)); 0038 end 0039 d=y(:,3); 0040 m=y(:,2); 0041 y=y(:,1); 0042 end 0043 mo=m+9; 0044 yr=y-1; 0045 i=find(m>2); 0046 mo(i)=m(i)-3; 0047 yr(i)=y(i); 0048 c = floor(yr/100); 0049 yr = yr - c*100; 0050 j = floor((146097*c)/4) + floor((1461*yr)/4) + ... 0051 floor((153*mo +2)/5) +d +1721119; 0052 0053 % If you want julian days to start and end at noon, 0054 % replace the following line with: 0055 % j=j+(h-12)/24; 0056 0057 j=j+h/24; 0058