int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str, fr_time_res_t hint)
{
int i;
- time_t t;
+ fr_unix_time_t t;
struct tm *tm, s_tm;
char buf[64];
char *p;
done:
t = fr_time_from_utc(tm);
- if (t == (time_t) -1) {
- fr_strerror_printf("Failed calling system function to parse time - %s",
- fr_syserror(errno));
- return -1;
- }
/*
* Add in the time zone offset, which the posix
tm->tm_min = atoi(f[1]);
}
- /*
- * Returns -1 on failure.
- */
t = fr_time_from_utc(tm);
- if (t == (time_t) -1) {
- fr_strerror_printf("Failed calling system function to parse time - %s",
- fr_syserror(errno));
- return -1;
- }
/*
* Get the UTC time, and manually add in the offset from GMT.
/*
* Based on https://blog.reverberate.org/2020/05/12/optimizing-date-algorithms.html
*/
-time_t fr_time_from_utc(struct tm *tm)
+fr_unix_time_t fr_time_from_utc(struct tm *tm)
{
static const uint16_t month_yday[12] = {0, 31, 59, 90, 120, 151,
181, 212, 243, 273, 304, 334};
void fr_time_elapsed_update(fr_time_elapsed_t *elapsed, fr_time_t start, fr_time_t end) CC_HINT(nonnull);
void fr_time_elapsed_fprint(FILE *fp, fr_time_elapsed_t const *elapsed, char const *prefix, int tabs) CC_HINT(nonnull(1,2));
-time_t fr_time_from_utc(struct tm *tm) CC_HINT(nonnull);
+fr_unix_time_t fr_time_from_utc(struct tm *tm) CC_HINT(nonnull);
#ifdef __cplusplus
}