Question:

Python : timedelta in years ?

by  |  earlier

0 LIKES UnLike

I am writing a simple program that displays a countdown in a console.

I want it to reset it for the same date of the next year once the countdown has reached 0.

For example, if the deadline is set to Christmas 2006, I want it simply to add years while the countdown isn't greater than 0 microseconds.

2006+1+1=2008

However, if I try this :

while countdown <= datetime.timedelta(0) :

deadline = deadline + datetime.datetime.year(1)

There's an error:

"TypeError: 'years' is an invalid keyword argument for this function"

I could simply add datetime.timedelta(days=365), but, now, there's a problem with leap years...

Please help me.

Thank you!

 Tags:

   Report

1 ANSWERS


  1. man this method deltatime() has NO keyword argument called &quot;years&quot; ; try a work around

    http://docs.python.org/lib/datetime-time...

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions