added functions to check if time is valid