timedelta comparision with gmtime()

F

Florian Lindner

Hello,
I want to know if a certain duration is over.
I try it like this with timedelta objects:

d = datetime.timedelta(minutes = 2)
t = time.gmtime()
print (t + d < time.gmtime())

gives:

TypeError: unsupported operand type(s) for +: 'datetime.timedelta' and
'time.struct_time'

How to do that right?

Thanks,

Florian
 
W

wittempj

martin@ubuntu:~ $ python
Use now() from datetime class of datetime module instead of time
module.

Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
py> import datetime
py> t = datetime.datetime.now()
py> print t
2005-06-22 20:22:36.212142
py> d = datetime.timedelta(minutes = 2)
py> print t + d
2005-06-22 20:24:36.212142
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top