473,513 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3962
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2006
by: Wil Schultz | last post by:
Hey all, Sorry, I am trying my best to learn python and seem to be able to grab somethings while others seem to escape me... I am trying to write a timedelta meter, i.e. "it has been U years, V...
0
1203
by: josh | last post by:
Why can't timedelta arithmetic be done on time objects? (e.g. datetime.time(5)-datetime.timedelta(microseconds=3) Nonzero "days" of the timedelta could either be ignored, or trigger an...
1
24515
by: KW | last post by:
Hi all, Appreciate if someone can help me out on this. Currently, I have a tm structure holding information of the UTC time, which is very likely to be in the past, meaning not the current...
11
4934
by: red floyd | last post by:
I have a copy of the C++ standard. Unfortunately, I don't have a copy of the C89 standard, and the question I have is related to something incorporated by reference. Specifically, what does the...
1
6796
by: Philipp | last post by:
Hello Pythonistas I'm new to Python, I hope you understand my question. I would like to pass a parameter "gap" to a function. gap should be used there to create a timedelta Object. from...
5
28414
by: Lad | last post by:
Hello, what is the best /easest way how to get number of hours and minutes from a timedelta object? Let's say we have aa=datetime.datetime(2006, 7, 29, 16, 13, 56, 609000)...
6
30588
by: Carl J. Van Arsdall | last post by:
Basically I used the datetime module and timedelta objects to calculate a difference between two times. Now I'm trying to figure out how I make that time delta a string HH:MM:SS to show elapsed...
2
13968
by: kath | last post by:
Hi, the following shows the contents of "datebook.xls" Date 8/9/2006 8/9/2006 8/9/2006 8/9/2006 8/9/2006
2
4287
by: skip | last post by:
Running from Subversion, I see confusing (to me) behavior related to division of datetime.timedelta objects by integers: % python Python 2.6a0 (trunk:57277:57280M, Aug 28 2007, 17:44:49) on...
0
7162
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7539
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5090
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.