26 #include <lal/LALStdlib.h>
28 #include <lal/AVFactories.h>
31 static int test(
struct tm *t,
int correct_gps)
36 tf.tm_wday = tf.tm_yday = -1;
38 XLAL_CHECK(tf.tm_wday == t->tm_wday,
XLAL_EFAILED,
"UTCtoGPSTest: incorrect day of week\n output = %d\n expected = %d\n", tf.tm_wday, t->tm_wday);
39 XLAL_CHECK(tf.tm_yday == t->tm_yday,
XLAL_EFAILED,
"UTCtoGPSTest: incorrect day of year\n output = %d\n expected = %d\n", tf.tm_yday, t->tm_yday);
42 t->tm_wday = t->tm_yday = -1;
46 if (gps != correct_gps)
49 strftime(buf,
sizeof(buf),
"%Y-%m-%d %H:%M:%S", t);
50 XLAL_ERROR(
XLAL_EFAILED,
"UTCtoGPSTest: incorrect UTC to GPS conversion\n input = %s\n output = %d\n expected = %d\n", buf, gps, correct_gps);
75 utcDate.tm_yday = 186;
86 utcDate.tm_yday = 181;
96 for (sec = 457056007; sec < 457056012; sec++)
99 utcDate.tm_sec = 58 + (sec - 457056007);
100 if (utcDate.tm_sec <= 60)
102 utcDate.tm_yday = 180;
105 utcDate.tm_mday = 30;
106 utcDate.tm_hour = 23;
111 utcDate.tm_sec -= 61;
112 utcDate.tm_yday = 181;
116 utcDate.tm_hour = 00;
119 utcDate.tm_isdst = 1;
123 utcDate.tm_year = 94;
124 utcDate.tm_yday = 319;
127 utcDate.tm_mday = 16;
131 utcDate.tm_isdst = 0;
135 const time_t max_32bit_unix_time = (time_t)
LAL_INT4_MAX;
136 const int max_32bit_unix_time_as_gps = 1831518865;
137 utcDate.tm_year = 138;
138 utcDate.tm_yday = 18;
141 utcDate.tm_mday = 19;
145 utcDate.tm_isdst = 0;
148 utcDate.tm_yday = 18;
void LALCheckMemoryLeaks(void)
static int test(struct tm *t, int correct_gps)
INT4 XLALUTCToGPS(const struct tm *utc)
Returns the GPS seconds since the GPS epoch for a specified UTC time structure.
time_t XLALSecondsSinceUnixEpoch(const struct tm *utc)
Compute Unix epoch time: seconds since 1970 January 1 0h UTC (POSIX:2001 definition of Unix Epoch).
struct tm * XLALFillUTC(struct tm *utc)
Fill in derived fields, e.g.
#define xlalErrno
Modifiable lvalue containing the XLAL error number.
#define XLAL_ERROR(...)
Macro to invoke a failure from a XLAL routine returning an integer.
#define XLAL_CHECK(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns an integ...
#define XLAL_CHECK_MAIN(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a C main() routine.
@ XLAL_SUCCESS
Success return value (not an error number)
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
@ XLAL_EFAILED
Generic failure.