centralize time validation and serialization