mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-01-18 12:28:20 -05:00
This is a follow-up to work provided by: Eric Wheeler, KJ7LNW <astronomy-git@z.ewheeler.org> Before now, the C function Astronomy_GetCurrentTime returned the current time from the system clock, but only with whole second resolution. Now it supports microsecond resolution on Linux/Unix, Mac OS, and Windows. For unsupported platforms, a compiler error will occur to indicate that microsecond resolution is not available. However, it is possible to define one of the following two preprocessor symbols to work around the compiler error: 1. ASTRONOMY_ENGINE_NO_CURRENT_TIME Excludes the function Astronomy_CurrentTime from the build. If your project does not need to obtain the current time, or your hardware platform does not provide current date and time in the first place, this is likely the better option. 2. ASTRONOMY_ENGINE_WHOLE_SECOND If your project does need to use the current date and time for astronomy calculations, and it can tolerate whole second resolution, this option provides a version of Astronomy_CurrentTime that uses a call to `time(NULL)`. Notes: - Added unit test to confirm at least millisecond resolution. Because these tests have to run on GitHub Actions cloud platform, and those systems can be heavily CPU-loaded, I want to be tolerant of resolution and avoid false failures. - Added detection of Mac platform. - Added preprocessor options documented above. - On Windows, use ULARGE_INTEGER and eliminated one integer division. - Added comments and developer documentation. - Converted tabs to spaces in astronomy.c, for consistent code format.
276 KiB
276 KiB