If you want to be exact, you need them all: days, months and years. The uears because of the leap day in February. The year is a leap year if the year is divisible by four, but not by 100, except if it's divisible by 400. Otherwise you might want to calculate days from the start of the year (takes care of different length months). Just have a table of days in each month and remember to add a day in february if it's a leap year.