MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / GetTimeNow

Function GetTimeNow

general.cpp:2297–2370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2295// return value filled is expressed in the given zone parameter.
2296
2297void GetTimeNow(int *mon, int *day, int *yea, real *tim, real dst, real zon)
2298{
2299#ifdef PC
2300 SYSTEMTIME st, lt;
2301 real jd;
2302 int dh;
2303
2304 GetSystemTime(&st);
2305 if (dst == dstAuto) {
2306 // Daylight field of 24 means autodetect whether Daylight Saving Time.
2307
2308 GetLocalTime(&lt);
2309 dh = NAbs(st.wHour - lt.wHour);
2310 if (dh > 12)
2311 dh = 24-dh;
2312 is.fDst = (dh == ciDefa.zon-1);
2313 dst = (real)is.fDst;
2314 }
2315 if (zon == zonLMT || zon == zonLAT)
2316 zon = ciDefa.lon / 15.0;
2317 jd = MdytszToJulian(st.wMonth, st.wDay, st.wYear,
2318 (real)(((st.wHour * 60 + st.wMinute + us.lTimeAddition) * 60 +
2319 st.wSecond) * 1000 + st.wMilliseconds) / (60.0 * 60.0 * 1000.0),
2320 0.0, -(zon-dst));
2321 *tim = (jd - RFloor(jd)) * 24.0;
2322 JulianToMdy(jd - 0.5, mon, day, yea);
2323#else
2324 time_t curtimer;
2325 int min, sec, i;
2326 real hr;
2327 CI ci;
2328
2329 time(&curtimer);
2330 sec = (int)(curtimer % 60);
2331 curtimer = curtimer / 60 + us.lTimeAddition;
2332 min = (int)(curtimer % 60);
2333 curtimer /= 60;
2334 if (zon == zonLMT || zon == zonLAT)
2335 zon = ciDefa.lon / 15.0;
2336 hr = (real)(curtimer % 24) - (zon - (dst == dstAuto ? 0.0 : dst));
2337 curtimer /= 24;
2338 while (hr < 0.0) {
2339 curtimer--;
2340 hr += 24.0;
2341 }
2342 while (hr >= 24.0) {
2343 curtimer++;
2344 hr -= 24.0;
2345 }
2346 curtimer += ldTime; // Number of days between 1/1/1970 and 1/1/4713 BC.
2347 JulianToMdy((real)curtimer, mon, day, yea);
2348 *tim = HMS(hr, min, sec);
2349 if (dst == dstAuto) {
2350 // Daylight field of 24 means autodetect whether Daylight Saving Time.
2351
2352 SetCI(ci, *mon, *day, *yea, *tim, 0.0, zon, ciDefa.lon, ciDefa.lat);
2353 if (DisplayAtlasLookup(ciDefa.loc, 0, &i) &&
2354 DisplayTimezoneChanges(is.rgae[i].izn, 0, &ci)) {

Callers 6

FProcessSwitchesFunction · 0.85
FOutputCalendarFileFunction · 0.85
FInputDataFunction · 0.85
DlgInfoFunction · 0.85
DlgTransitFunction · 0.85
DlgProgressFunction · 0.85

Calls 4

MdytszToJulianFunction · 0.85
JulianToMdyFunction · 0.85
DisplayAtlasLookupFunction · 0.85
DisplayTimezoneChangesFunction · 0.85

Tested by

no test coverage detected