Refactored and added setDate functionality.