21 dsrc(double d, Tim *t, int i)
37 dtsetup(double d, Tim *t)
41 t->ifa[0] = floor(1900 + d/365.24220);
46 t->ifa[1] = floor(1 + dsrc(d, t, 0)/30);
47 t->ifa[2] = floor(1 + dsrc(d, t, 1));
50 v = (d - convdate(t)) * 24;
52 t->ifa[4] = (v - t->ifa[3]) * 60;
53 convdate(t); /* to set timezone */
65 print("%s ", month[i-1]);
88 dtsetup(d + .5/(24*60), &t);
102 print("%s exactly ...", mer);
108 print("%s ...", mer);
111 /* hour minute second */
115 s = floor((t.ifa[4]-m) * 60);
116 print("%.2d:%.2d:%.2d %.*s", h, m, s, utfnlen(t.tz, 3), t.tz);
166 // uses lambda, beta, rad, motion
167 // sets alpha, delta, rp
171 // uses alpha, delta, rp
172 // sets ra, decl, lha, decl2, az, el
176 print(" %R %D %D %4.0f", lha, nlat, awlong, elev/3.28084);
188 print("%s ", decade[n/10 - 2]);
193 print("%s ", unit[n]);
197 tzone(double y, Tim *z)
203 * get a rough approximation to unix mean time
205 t = (y - 25567.5) * 86400;
208 * if outside unix conversions,
211 if(t < 0 || t > 2.1e9)
215 * convert by both local and gmt
217 t1 = *localtime((long)t);
218 t2 = *gmtime((long)t);
221 * pick up year crossings
223 if(t1.yday == 0 && t2.yday > 1)
225 if(t2.yday == 0 && t1.yday > 1)
229 * convert times to days
231 l1 = t1.yday + t1.hour/24. + t1.min/1440. + t1.sec/86400.;
232 l2 = t2.yday + t2.hour/24. + t2.min/1440. + t2.sec/86400.;
237 strncpy(z->tz, t1.zone, sizeof(z->tz));
238 return y + (l2 - l1);
258 * input date conversion
259 * output is done by zero crossing
260 * on this input conversion.
273 * normalize the month
294 if(fmod(y, 4) == 0 && m > 2)
296 y = y*365 + floor((y+3)/4) + dmo[m-1] + d - 1;
302 y -= floor((y-1794167)/36524.220) -
303 floor((y-1721117)/146100);
304 y += t->ifa[3]/24 + t->ifa[4]/1440 - 2415020.5;
307 * kitchen clock correction
309 strncpy(t->tz, "GMT", sizeof(t->tz));