Fixed localize_time function