Lines 207-213 and 215-221 can easily be refactored to remove code duplication. You can define the helper function directly within set_date_and_time, passing in the css and desired value.