added a function to calculate the date