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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
use *;
use DateTime;
use *;
/* -----------------------------------------------------------------------------
*
* procedure days2mdhms
*
* this procedure converts the day of the year, days, to the equivalent month
* day, hour, minute and second.
*
* algorithm : set up array for the number of days per month
* find leap year - use 1900 because 2000 is a leap year
* loop through a temp value while the value is < the days
* perform int conversions to the correct day and month
* convert remainder into h m s using type conversions
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* year - year 1900 .. 2100
* days - julian day of the year 0.0 .. 366.0
*
* outputs :
* mon - month 1 .. 12
* day - day 1 .. 28,29,30,31
* hour - hour 0 .. 23
* min - minute 0 .. 59
* sec - second 0.0 .. 59.999
*
* locals :
* dayofyr - day of year
* temp - temporary extended values
* inttemp - temporary int value
* i - index
* lmonth[12] - int array containing the number of days per month
*
* coupling :
* none.
* --------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
*
* procedure jday
*
* this procedure finds the julian date given the year, month, day, and time.
* the julian date is defined by each elapsed day since noon, jan 1, 4713 bc.
*
* algorithm : calculate the answer in one step for efficiency
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* year - year 1900 .. 2100
* mon - month 1 .. 12
* day - day 1 .. 28,29,30,31
* hour - universal time hour 0 .. 23
* min - universal time min 0 .. 59
* sec - universal time sec 0.0 .. 59.999
*
* outputs :
* jd - julian date days from 4713 bc
*
* locals :
* none.
*
* coupling :
* none.
*
* references :
* vallado 2007, 189, alg 14, ex 3-14
*
* --------------------------------------------------------------------------- */
// pub fn invjday(jd: f64, as_array: bool) {
// // --------------- find year and days of the year -
// let temp = jd - 2415019.5;
// let tu = temp / 365.25;
// let mut year = 1900.0 + (tu).floor();
// let mut leapyrs = ((year - 1901.0) * 0.25).floor();
// // optional nudge by 8.64x10-7 sec to get even outputs
// let mut days = (temp - (((year - 1900.0) * 365.0) + leapyrs)) + 0.00000000001;
// // ------------ check for case of beginning of a year -----------
// if days < 1.0 {
// year -= 1.0;
// leapyrs = ((year - 1901.0) * 0.25).floor();
// days = temp - (((year - 1900.0) * 365.0) + leapyrs);
// }
// // ----------------- find remaing data -------------------------
// let mdhms = days2mdhms(year as u32, days as f64);
// let mon = mdhms.month;
// let day = mdhms.day;
// let hour = mdhms.hour;
// let minute = mdhms.minute;
// let sec = mdhms.second as f64 - 0.00000086400;
// // todo
// if (as_array) {
// return [year, mon as f64, day as f64, hour as f64, minute as f64, sec.floor()];
// }
// // return new Date(Date.UTC(year, mon - 1, day, hour, minute, Math.floor(sec)));
// }