DATE2JD Julian day number from Gregorian date. JD = DATE2JD(YEAR, MONTH, DAY, HOUR, MINUTE, SECOND) returns the Julian day number of the given date (Gregorian calendar) plus a fractional part depending on the 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. Start of the JD (Julian day) count is from 0 at 12 noon 1 January -4712 (4713 BC), Julian proleptic calendar. Note that this day count conforms with the astronomical convention starting the day at noon, in contrast with the civil practice where the day starts with midnight. Astronomers have used the Julian period to assign a unique number to every day since 1 January 4713 BC. This is the so-called Julian Day (JD). JD 0 designates the 24 hours from noon UTC on 1 January 4713 BC (Julian proleptic calendar) to noon UTC on 2 January 4713 BC.

- date2mjd DATE2MJD Modified Julian day number.
- date2unixsecs DATE2UNIXSECS Number of seconds since 00:00:00 1 January 1970.
- dayofyear_inverse DAYOFYEAR_INVERSE if you have the day of year and want the month and day.
- unixsecs2date UNIXSECS2DATE Number of seconds since 00:00:00 1 January 1970 to date.

0001 function jd = date2jd(varargin) 0002 %DATE2JD Julian day number from Gregorian date. 0003 % 0004 % JD = DATE2JD(YEAR, MONTH, DAY, HOUR, MINUTE, SECOND) returns the Julian 0005 % day number of the given date (Gregorian calendar) plus a fractional part 0006 % depending on the time of 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. 0012 % 0013 % Start of the JD (Julian day) count is from 0 at 12 noon 1 January -4712 0014 % (4713 BC), Julian proleptic calendar. Note that this day count conforms 0015 % with the astronomical convention starting the day at noon, in contrast 0016 % with the civil practice where the day starts with midnight. 0017 % 0018 % Astronomers have used the Julian period to assign a unique number to 0019 % every day since 1 January 4713 BC. This is the so-called Julian Day 0020 % (JD). JD 0 designates the 24 hours from noon UTC on 1 January 4713 BC 0021 % (Julian proleptic calendar) to noon UTC on 2 January 4713 BC. 0022 0023 % Sources: - http://tycho.usno.navy.mil/mjd.html 0024 % - The Calendar FAQ (http://www.faqs.org) 0025 0026 % Author: Peter J. Acklam 0027 % Time-stamp: 2002-05-24 13:30:06 +0200 0028 % E-mail: pjacklam@online.no 0029 % URL: http://home.online.no/~pjacklam 0030 0031 nargsin = nargin; 0032 error(nargchk(0, 6, nargsin)); 0033 if nargsin 0034 argv = {1 1 1 0 0 0}; 0035 argv(1:nargsin) = varargin; 0036 else 0037 argv = num2cell(clock); 0038 end 0039 [year, month, day, hour, minute, second] = deal(argv{:}); 0040 0041 % The following algorithm is a modified version of the one found in the 0042 % Calendar FAQ. 0043 0044 a = floor((14 - month)/12); 0045 y = year + 4800 - a; 0046 m = month + 12*a - 3; 0047 0048 % For a date in the Gregorian calendar: 0049 jd = day + floor((153*m + 2)/5) ... 0050 + y*365 + floor(y/4) - floor(y/100) + floor(y/400) - 32045 ... 0051 + ( second + 60*minute + 3600*(hour - 12) )/86400;

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