Fix possible errors for invalid times