Refactored time to use date object