localtime() can return NULL due to weird value from time()