don't write past end of buffer with gettimeofday