#include <stdio.h>
#include "novas.h"
int main() {
long test_values[3] = {1748314880, 1752799060, 1755929180};
novas_timespec ts;
char iso_timestamp[40];
for (int i = 0; i < 3; i++) {
long unixtime = test_values[i];
novas_set_unix_time(unixtime, 0, 0.0, 0.0, &ts) != 0;
novas_iso_timestamp(&ts, iso_timestamp, sizeof(iso_timestamp));
double jd = novas_get_time(&ts, NOVAS_UTC);
printf("%ld | %17.10f | %s\n", unixtime, jd, iso_timestamp);
}
return 0;
}
$ ./example-unixtime
1748314880 | 2460822.6259259260 | 2025-05-27T03:01:110.000Z
1752799060 | 2460874.5261574076 | 2025-07-18T00:37:310.000Z
1755929180 | 2460910.7543981480 | 2025-08-23T06:06:110.000Z
Test:
Output:
Looks like, due to floating-point calculations,
sat some point (L1007) becomes19.9(9)or39.9(9)instead of20or40, which produces incorrect seconds value in the resulting timestamp:https://github.com/Smithsonian/SuperNOVAS/blob/c2449e1cae2d14a0c37379cb0d515d4e201c82fb/src/timescale.c#L1001-L1007