amiga-tz/library/time_offtime.c

36 lines
789 B
C

#include "time_header.h"
struct tm __offtime_tm;
struct tm* offtime(const time_t *const timep, long offset)
{
struct tm *tmp;
if ((offset > 0 && offset > INT_FAST32_MAX) ||
(offset < 0 && offset < INT_FAST32_MIN)) {
errno = EOVERFLOW;
return NULL;
}
tmp = gmtsub(NULL, timep, (int_fast32_t)offset, &__offtime_tm);
if (tmp == NULL)
errno = EOVERFLOW;
return tmp;
}
struct tm* offtime_r(const time_t *timep, long offset, struct tm *tmp)
{
if ((offset > 0 && offset > INT_FAST32_MAX) ||
(offset < 0 && offset < INT_FAST32_MIN)) {
errno = EOVERFLOW;
return NULL;
}
tmp = gmtsub(NULL, timep, (int_fast32_t)offset, tmp);
if (tmp == NULL)
errno = EOVERFLOW;
return tmp;
}