Bugs item #1646728, was opened at 2007-01-29 10:21
Message generated for change (Comment added) made by jhenstridge
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1646728&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: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: James Henstridge (jhenstridge)
Assigned to: Nobody/Anonymous (nobody)
Summary: datetime.fromtimestamp fails with negative fractional times

Initial Comment:
The datetime.fromtimestamp() function works fine with integer timestamps and 
positive fractional timestamps, but fails if I pass a negative fractional 
timestamp.  For example:

>>> import datetime
>>> datetime.datetime.fromtimestamp(-1.05)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: microsecond must be in 0..999999

It should return the same result as datetime.fromtimestamp(-1) - 
timedelta(seconds=.5).

The same bug can be triggered in datetime.utcfromtimestamp().

I have been able to reproduce this bug in Python 2.4.4 and Python 2.5 on Linux.

----------------------------------------------------------------------

>Comment By: James Henstridge (jhenstridge)
Date: 2007-03-05 18:23

Message:
Logged In: YES 
user_id=146903
Originator: YES

The problem seems to be in datetime_from_timestamp() from
datetimemodule.c.  It should probably be checking to see whether the
microseconds value it calculates is negative, and adjust "timet" and "us"
accordingly if so.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2007-03-03 00:05

Message:
Logged In: YES 
user_id=6380
Originator: NO

Looks like a bug in the conversion from floats to ints.  Anyone care to
track it down more precisely?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1646728&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to