Home > atmlab > time > jdate2jd.m

jdate2jd

PURPOSE ^

JDATE2JD Julian day number from Julian date.

SYNOPSIS ^

function jd = jdate2jd(varargin)

DESCRIPTION ^

JDATE2JD Julian day number from Julian date.

   JDATE2JD(YEAR, MONTH, DAY, HOUR, MINUTE, SECOND) returns the Julian day
   number of the given date (Julian 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 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 ^

jdate2jd.m

SOURCE CODE ^

0001 function jd = jdate2jd(varargin)
0002 %JDATE2JD Julian day number from Julian date.
0003 %
0004 %   JDATE2JD(YEAR, MONTH, DAY, HOUR, MINUTE, SECOND) returns the Julian day
0005 %   number of the given date (Julian 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 JAN -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 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:31:03 +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 from the Calendar FAQ.  The one in the
0042    % Calendar FAQ is correct back to, and including, -4800-03-01 Julian
0043    % proleptic calendar.  The algorithm below is correct for all dates in
0044    % the Julian proleptic calendar.
0045 
0046    a = floor((14 - month)/12);
0047    y = year + 4800 - a;
0048    m = month + 12*a - 3;
0049 
0050    jd = day + floor((153*m + 2)/5) + y*365 + floor(y/4) - 32083 ...
0051         + ( second + 60*minute + 3600*(hour - 12) )/86400;

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