refactoring - adding function to create date and time objects