Updated time type cast to handle Date objects.