I'm using the datetime module, i.e.: >>> import datetime >>> today = datetime.datetime.now() >>> print(today) 2009-03-06 13:24:58.857946 and I would like to compute the day of year that takes leap years into account. e.g. today (March 6, 2009) is the 65th day of 2009. I see a two options: Create a number_of_days_in_month = [31, 28, ...] array, decide if it's a leap year and manually sum up the day