Fixed potential bug with time format check and replaced sprintf
functions in error handling.