class for working with dates and refactor