Bugs item #1569623, was opened at 2006-10-02 19:16 Message generated for change (Comment added) made by tim_one You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1569623&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: Extension Modules >Group: Not a Bug >Status: Closed >Resolution: Invalid Priority: 5 Submitted By: David Fugate (dfugate_ms) Assigned to: Nobody/Anonymous (nobody) Summary: datetime.datetime subtraction bug Initial Comment: Python version: 2.5 OS name and version: Windows XP SP2 Email: [EMAIL PROTECTED] The datetime.datetime subtraction operator seems to have a bug in it: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> import datetime >>> x = datetime.datetime(2006, 9, 29, 15, 37, 28, 686001) >>> y = datetime.datetime(2006, 9, 29, 15, 37, 28, 686000) >>> x - y datetime.timedelta(0, 0, 1) >>> y - x datetime.timedelta(-1, 86399, 999999) Here, the result of y - x should be timedelta(0, 0, -1). ---------------------------------------------------------------------- >Comment By: Tim Peters (tim_one) Date: 2006-10-02 19:27 Message: Logged In: YES user_id=31435 Sorry, nope. As the timedelta docs say: """ ... days, seconds and microseconds are then normalized so that the representation is unique, with 0 <= microseconds < 1000000 0 <= seconds < 3600*24 (the number of seconds in one day) -999999999 <= days <= 999999999 ... If the normalized value of days lies outside the indicated range, OverflowError is raised. Note that normalization of negative values may be surprising at first. For example, >>> d = timedelta(microseconds=-1) >>> (d.days, d.seconds, d.microseconds) (-1, 86399, 999999) """ Which is exactly what you're seeing. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1569623&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com