May-01-2017, 02:56 AM
Calendars are not easy. Though I think leap years is the main complication. Time is even worse, with timezones making things very wacky.
Unless you have a good reason to do otherwise, you should probably just use a library.
Unless you have a good reason to do otherwise, you should probably just use a library.
>>> import datetime as dt >>> left = dt.date(1999, 11, 24) >>> right = dt.date(2001, 3, 2) >>> abs(left - right).days 464