Date manipulation in Python

David Brady daves_spam_dodging_account at yahoo.com
Mon Dec 10 11:10:44 EST 2001


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?

Thanks!

-dB

=====
David Brady
daves_spam_dodging_account at yahoo.com
I'm feeling very surreal today... or *AM* I?

__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com




More information about the Python-list mailing list