-
Notifications
You must be signed in to change notification settings - Fork 1
/
greg2Julian.m
54 lines (52 loc) · 2.17 KB
/
greg2Julian.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function [JDay,JD]=greg2Julian(year,month,day,hour,min,sec)
% -----------------------------------------------------------------------------------------------------------
% This function converts the Gregorian dates to Julian dates.
%
% 0. Syntax:
% [JD,julianday] = juliandate(year,month,day,hour,min,sec)
%
% 1. Inputs:
% year, month, day = date in Gregorian calendar.
% hour,min,sec = time at universal time.
%
% 2. Outputs:
% JD = Julian date.
% julianday = day of week.
%
% 3. Example:
% >> [a,b] = greg2julian(2006,5,30,2,30,28)
% a =
% 2453885.60449074
% b =
% Tuesday
%
% 4. Notes:
% - For all common era (CE) dates in the Gregorian calendar, and for more
% information, check the referents.
% - The function was tested, using the julian date converter of U.S. Naval Observatory and
% the results were similar. You can check it.
% - Trying to do the life... more easy with the conversions.
%
% 5. Referents:
% Astronomical Applications Department. "Julian Date Converter". From U.S. Naval Observatory.
% http://aa.usno.navy.mil/data/docs/JulianDate.html
% Duffett-Smith, P. (1992). Practical Astronomy with Your Calculator.
% Cambridge University Press, England: pp. 9.
% Seidelmann, P. K. (1992). Explanatory Supplement to the Astronomical Almanac.
% University Science Books, USA. pp. 55-56.
% Weisstein, Eric W. "Julian Date". From World of Astronomy--A Wolfram Web Resource.
% http://scienceworld.wolfram.com/astronomy/JulianDate.html
%
% Gabriel Ruiz Mtz.
% May-2006
%
% Modifications:
% 04/06/06: To find the days, it was only changed the loop to a cell array. Thanks to Jérôme.
% ------------------------------------------------------------------------------------------------------------
error(nargchk(6,6,nargin))
timeut = hour + ( min / 60 ) + ( sec / 3600 );
%For common era (CE), anno domini (AD)
JDay = ( 367 * year ) - floor ( 7 * ( year + floor( ( month + 9 ) / 12 ) ) / 4 ) - ...
floor( 3 * ( floor( ( year + ( month - 9 ) / 7 ) / 100 ) + 1 ) / 4 ) + ...
floor( ( 275 * month ) / 9 ) + day + 1721028.5;
JD = JDay + ( timeut / 24 );