469,949 Members | 2,183 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,949 developers. It's quick & easy.

timedelta comparision with gmtime()

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
Jul 19 '05 #1
1 3719
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

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Wil Schultz | last post: by
reply views Thread by josh | last post: by
11 posts views Thread by red floyd | last post: by
1 post views Thread by Philipp | last post: by
6 posts views Thread by Carl J. Van Arsdall | last post: by
2 posts views Thread by skip | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.