Separated date adaption logic from UI and added automated tests for logic