dt_status_t dt_init_interval()

in src/dt.c [251:268]


dt_status_t dt_init_interval(unsigned long seconds, unsigned long nano_seconds, dt_interval_t *result)
{
    unsigned long seconds_delta = 0;
    if (!result) {
        return DT_INVALID_ARGUMENT;
    }

    seconds_delta = nano_seconds / 1000000000UL;

    if (is_unsigned_long_sum_overflows(seconds, seconds_delta) == DT_TRUE) {
        return DT_OVERFLOW;
    }

    result->seconds = seconds + seconds_delta;
    result->nano_seconds = nano_seconds % 1000000000UL;

    return DT_OK;
}