diff options
| author | Mattias Andrée <m@maandree.se> | 2025-03-07 22:41:56 +0100 | 
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2025-03-07 22:41:56 +0100 | 
| commit | 0f3f611508fbd4ad0704f1e1352fcbdd7ee512c7 (patch) | |
| tree | 8201d83a999d3eab5b99159dadf4fee2cd73a74d | |
| parent | Fix bugs (diff) | |
| download | libred-master.tar.gz libred-master.tar.bz2 libred-master.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | solar.c | 40 | 
1 files changed, 40 insertions, 0 deletions
| @@ -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 | 
