JD2DATE Gregorian calendar date from modified Julian day number. [YEAR, MONTH, DAY, HOUR, MINUTE, SECOND] = JD2DATE(JD) returns the Gregorian calendar date (year, month, day, hour, minute, and second) corresponding to the Julian day number JD. Start of the JD (Julian day) count is from 0 at 12 noon 1 JAN -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 calendar) to noon UTC on 2 January 4713 BC.
0001 function [year, month, day, hour, minute, second] = jd2date(jd) 0002 %JD2DATE Gregorian calendar date from modified Julian day number. 0003 % 0004 % [YEAR, MONTH, DAY, HOUR, MINUTE, SECOND] = JD2DATE(JD) returns the 0005 % Gregorian calendar date (year, month, day, hour, minute, and second) 0006 % corresponding to the Julian day number JD. 0007 % 0008 % Start of the JD (Julian day) count is from 0 at 12 noon 1 JAN -4712 0009 % (4713 BC), Julian proleptic calendar. Note that this day count conforms 0010 % with the astronomical convention starting the day at noon, in contrast 0011 % with the civil practice where the day starts with midnight. 0012 % 0013 % Astronomers have used the Julian period to assign a unique number to 0014 % every day since 1 January 4713 BC. This is the so-called Julian Day 0015 % (JD). JD 0 designates the 24 hours from noon UTC on 1 January 4713 BC 0016 % (Julian calendar) to noon UTC on 2 January 4713 BC. 0017 0018 % Sources: - http://tycho.usno.navy.mil/mjd.html 0019 % - The Calendar FAQ (http://www.faqs.org) 0020 0021 % Author: Peter J. Acklam 0022 % Time-stamp: 2002-05-24 15:24:45 +0200 0023 % E-mail: pjacklam@online.no 0024 % URL: http://home.online.no/~pjacklam 0025 0026 nargsin = nargin; 0027 error(nargchk(1, 1, nargsin)); 0028 0029 % Adding 0.5 to JD and taking FLOOR ensures that the date is correct. 0030 % Here are some sample values: 0031 % 0032 % MJD Date Time 0033 % -1.00 = 1858-11-16 00:00 (not 1858-11-15 24:00!) 0034 % -0.75 = 1858-11-16 06:00 0035 % -0.50 = 1858-11-16 12:00 0036 % -0.25 = 1858-11-16 18:00 0037 % 0.00 = 1858-11-17 00:00 (not 1858-11-16 24:00!) 0038 % +0.25 = 1858-11-17 06:00 0039 % +0.50 = 1858-11-17 12:00 0040 % +0.75 = 1858-11-17 18:00 0041 % +1.00 = 1858-11-18 00:00 (not 1858-11-17 24:00!) 0042 0043 ijd = floor(jd + 0.5); % integer part 0044 0045 if nargout > 3 0046 fjd = jd - ijd + 0.5; % fraction part 0047 [hour, minute, second] = days2hms(fjd); 0048 end 0049 0050 % The following algorithm is from the Calendar FAQ. 0051 0052 a = ijd + 32044; 0053 b = floor((4 * a + 3) / 146097); 0054 c = a - floor((b * 146097) / 4); 0055 0056 d = floor((4 * c + 3) / 1461); 0057 e = c - floor((1461 * d) / 4); 0058 m = floor((5 * e + 2) / 153); 0059 0060 day = e - floor((153 * m + 2) / 5) + 1; 0061 month = m + 3 - 12 * floor(m / 10); 0062 year = b * 100 + d - 4800 + floor(m / 10);