-
Notifications
You must be signed in to change notification settings - Fork 1
/
julian.m
executable file
·70 lines (49 loc) · 1.12 KB
/
julian.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function jdate = julian (month, day, year)
% Julian date
% Input
% month = calendar month [1 - 12]
% day = calendar day [1 - 31]
% year = calendar year [yyyy]
% Output
% jdate = Julian date
% special notes
% (1) calendar year must include all digits
% (2) will report October 5, 1582 to October 14, 1582
% as invalid calendar dates and stop
% Orbital Mechanics with Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y = year;
m = month;
b = 0;
c = 0;
if (m <= 2)
y = y - 1;
m = m + 12;
end
if (y < 0)
c = -.75;
end
% check for valid calendar date
if (year < 1582)
% null
elseif (year > 1582)
a = fix(y / 100);
b = 2 - a + floor(a / 4);
elseif (month < 10)
% null
elseif (month > 10)
a = fix(y / 100);
b = 2 - a + floor(a / 4);
elseif (day <= 4)
% null
elseif (day > 14)
a = fix(y / 100);
b = 2 - a + floor(a / 4);
else
clc; home;
fprintf('\n\n this is an invalid calendar date!!\n');
keycheck;
return;
end
jd = fix(365.25 * y + c) + fix(30.6001 * (m + 1));
jdate = jd + day + b + 1720994.5;