[ python-Feature Requests-1487389 ] datetime.time and datetime.timedelta
SourceForge.net
noreply at sourceforge.net
Sat May 13 17:49:33 CEST 2006
Feature Requests item #1487389, was opened at 2006-05-12 13:13
Message generated for change (Comment added) made by fresh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1487389&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Chris Withers (fresh)
Assigned to: Nobody/Anonymous (nobody)
Summary: datetime.time and datetime.timedelta
Initial Comment:
print datetime.time(hour=0)+datetime.timedelta(hours=1)
...gives...
TypeError: unsupported operand type(s) for +:
'datetime.time' and 'datetime.timedelta'
Which is a bit frustrating :-/
Does it really need to be this way?
Chris
----------------------------------------------------------------------
>Comment By: Chris Withers (fresh)
Date: 2006-05-13 15:49
Message:
Logged In: YES
user_id=24723
Well, I think the OverflowError is perfectly correct, and
lets the software author handle that situation in any way
they want.
That said, you could add a keyword option to the
datetime.time constructor to allow it either to wrap round,
or raise OverflowError, with the overflow being the default.
If I resulted up patches for these, how would I get them
into a python release?
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2006-05-12 16:15
Message:
Logged In: YES
user_id=31435
Since the lack of arithmetic on `time` objects is both
intended and documented, this isn't "a bug". I moved this
to the Feature Requests tracker.
The problem with arithmetic on time objects is that it's not
obvious what to do in case of overflow or underflow: wrap
around or raise OverflowError? Either way violates _some_
reasonable expectation. Embed your time in a `datetime`
object and then you can decide what you want to do. For
example, if you want to wrap around,
>>> print (datetime.combine(date.today(), time(hour=0)) -
timedelta(hours=1)).time()
23:00:00
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1487389&group_id=5470
More information about the Python-bugs-list
mailing list