Date manipulation in Python

Cameron Laird claird at starbase.neosoft.com
Mon Dec 10 12:40:51 EST 2001


In article <mailman.1008000726.11872.python-list at python.org>,
David Brady  <daves_spam_dodging_account at yahoo.com> wrote:
>Hello,
>
>Firstoff, thanks to all the great answers I keep
>getting on this list.  I hope I'm not annoying
>everyone... :-)
>
>I am writing a tool that prints calendar/planner pages
>for me.  I know how to get today's date and day of the
>week from strftime and localtime... but I'd like to be
>able to move around in the date and still be able to
>print out the correct calendar.  For example, if today
>were Saturday, December 1st, I'd like to be able to
>show the week from Monday, November 26th through
>Sunday, December 30th.
>
>My initial impulse is to figure out which time format
>returns epoch seconds, and then add and subtract
>86,400 seconds per day to move around in the date. 
>But somehow I also think that "Guido has thoughtfully
>shot me in the foot years ago."  :-)
>
>Oh, one last thing.  A coworker *also* has a similar
>need, only he needs to go back to exactly midnight of
>a certain day of the week, and get the epoch seconds
>to return a hardcoded timestamp.
>
>Is there a good, Python way to do this?  ...of course
>there is.  It just may not be written yet.  If it is,
>would someone share?
			.
			.
			.
Prepare to fall in love.
<URL: http://www.lemburg.com/files/python/mxDateTime.html >
does this, and much more.
-- 

Cameron Laird <Cameron at Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



More information about the Python-list mailing list