Python Forum
Calendar calcualtions
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calendar calcualtions
#11
(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 ?!
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#12
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Task calendar problem humanical 8 1,588 Sep-04-2023, 02:55 PM
Last Post: Pedroski55
  Calendar program louienyy 2 4,872 Mar-30-2020, 01:21 PM
Last Post: louienyy
Sad [Learning] Calendar without modules or list KoFu 5 4,718 Sep-09-2019, 03:25 PM
Last Post: DeaD_EyE
  Calendar calculations frequency 10 5,534 Nov-13-2018, 07:34 PM
Last Post: frequency

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020