Python Forum

Full Version: Calendar calcualtions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(May-01-2017, 12:00 AM)Larz60+ Wrote: [ -> ]Here is an excellent resource for all sorts of date and time calculations: http://pleac.sourceforge.net/pleac_pytho...times.html
Homework forum ?!
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.
>>> import datetime as dt
>>> left = dt.date(1999, 11, 24)
>>> right = dt.date(2001, 3, 2)
>>> abs(left - right).days
464
Pages: 1 2