Quick Python question
Adam Russell
rus20376-oL8XVplsoaEqDJ6do+/SaQ at public.gmane.org
Thu Oct 8 12:29:26 EDT 2009
Back when I had a lot of date processing to do in Python
mxDateTime was a huge time saver!
Check it out:
http://www.egenix.com/products/python/mxBase/mxDateTime/
>Message: 10
>Date: Thu, 08 Oct 2009 11:03:38 -0400
>From: Jerry Feldman <gaf-mNDKBlG2WHs at public.gmane.org>
>Subject: Quick Python question
>To: Boston Linux and Unix <discuss-mNDKBlG2WHs at public.gmane.org>
>Message-ID: <4ACDFF4A.2010704-mNDKBlG2WHs at public.gmane.org>
>Content-Type: text/plain; charset="iso-8859-1"
>
>Recently, I've had to start writing some Python code. My question is
>specific to the datetime object.
>Basically, given a date, I need to add years to that date. One way to do
>it is:
>
>from datetime import date
>d = date.today() # initialize d to some date
>d = date(d.year + 1, d.month, d.day)
>
>In the above case I'm setting a date object d to todays date, then
>advancing it to the next year. Is there a more elegant or efficient way
>of doing this in Python. The above method certainly works fine except
>for February 29th, which is not important.
More information about the Discuss
mailing list