Home > atmlab > time > mjd2date.m

mjd2date

PURPOSE ^

MJD2DATE Gregorian calendar date from Julian day number.

SYNOPSIS ^

function [year, month, day, hour, minute, second] = mjd2date(mjd)

DESCRIPTION ^

MJD2DATE Gregorian calendar date from Julian day number.

   [YEAR, MONTH, DAY, HOUR, MINUTE, SECOND] = MJD2DATE(MJD) returns the
   Gregorian calendar date (year, month, day, hour, minute, and second)
   corresponding to the Julian day number JDAY.

   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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

mjd2date.m

SOURCE CODE ^

0001 function [year, month, day, hour, minute, second] = mjd2date(mjd)
0002 %MJD2DATE Gregorian calendar date from Julian day number.
0003 %
0004 %   [YEAR, MONTH, DAY, HOUR, MINUTE, SECOND] = MJD2DATE(MJD) returns the
0005 %   Gregorian calendar date (year, month, day, hour, minute, and second)
0006 %   corresponding to the Julian day number JDAY.
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-03-03 12:50:30 +0100
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    % We could have got everything by just using
0030    %
0031    %   jd = mjd2jd(mjd);
0032    %   [year, month, day, hour, minute, second] = jd2date(jd);
0033    %
0034    % but we lose precision in the fraction part when MJD is converted to JD
0035    % because of the large offset (2400000.5) between JD and MJD.
0036 
0037    jd = mjd2jd(mjd);
0038    [year, month, day] = jd2date(jd);
0039 
0040    if nargout > 3
0041       fmjd = mjd - floor(mjd);
0042       [hour, minute, second] = days2hms(fmjd);
0043    end

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