static dt_status_t dt_apply_interval_forward()

in src/dt.c [193:212]


static dt_status_t dt_apply_interval_forward(const dt_timestamp_t *lhs, const dt_interval_t *duration, dt_timestamp_t *result)
{

    unsigned long duration_seconds_full_part = 0UL;
    unsigned long nanoseconds_second_part = 0UL;
    unsigned long nano_seconds = 0UL;
    unsigned long max = LONG_MAX;

    nano_seconds = lhs->nano_second + duration->nano_seconds;//cannot be owerflowed
    nanoseconds_second_part = nano_seconds / 1000000000UL;
    duration_seconds_full_part = duration->seconds + nanoseconds_second_part;
    if (is_unsigned_long_sum_overflows(duration->seconds, nanoseconds_second_part) == DT_TRUE ||
            (duration_seconds_full_part >  max - lhs->second)) {
        return DT_OVERFLOW;
    }

    result->second = duration_seconds_full_part + lhs->second;
    result->nano_second = nano_seconds % 1000000000UL;
    return DT_OK;
}