added helper functions and error checks to date processing