diff options
Diffstat (limited to '')
| -rw-r--r-- | libred_get_colour.3 | 2 | ||||
| -rw-r--r-- | solar.c | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/libred_get_colour.3 b/libred_get_colour.3 index d6649d2..e271325 100644 --- a/libred_get_colour.3 +++ b/libred_get_colour.3 @@ -82,7 +82,7 @@ Upon successful completion, the .BR libred_get_colour () and .BR libred_get_colour_xy () -function returns 0. On failure, the function returns -1 and sets +functions return 0. On failure, the functions return -1 and set .I errno to indicate the error. .SH ERRORS @@ -26,6 +26,46 @@ double libred_solar_elevation(double latitude, double longitude, double *elevation); +#if !defined(_POSIX_TIMERS) +# ifndef CLOCK_REALTIME_COARSE +# define CLOCK_REALTIME_COARSE 0 +# endif +# ifndef CLOCK_REALTIME +# define CLOCK_REALTIME 0 +# endif +# if defined(_WIN32) +# include <windows.h> +int +clock_gettime(int clockid, struct timespec *ts) +{ + /* https://learn.microsoft.com/en-us/windows/win32/sysinfo/file-times */ + FILETIME ft; + ULARGE_INTEGER u64; + (void) clockid; + GetSystemTimePreciseAsFileTime(&ft); + u64.LowPart = ft.dwLowDateTime; + u64.HighPart = ft.dwHighDateTime; + ts->tv_sec = (time_t)(uli.QuadPart / 100000000ULL - 11644473600ULL); + ts->tv_nsec = (long)(uli.QuadPart % 100000000ULL * 10ULL); + return 0; +} +# else +# include <sys/time.h> +int +clock_gettime(int clockid, struct timespec *ts) +{ + struct timeval tv; + (void) clockid; + if (gettimeofday(&tv, NULL)) + return -1; + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * 1000; + return 0; +} +# endif +#endif + + /** * Get current Julian Centuries time (100 Julian Days since J2000) * and Julian Day time |
