fix integer overflows in time_t/struct tm conversion code