• Barry Warsaw's avatar
    Tim made this work. I knew we could count on him! :) Here's his · cc393366
    Barry Warsaw authored
    original checkin message:
    
        DateTime.__init__() and DateTime.__str__():  When a fractional
        number of seconds is passed in or derived, round it to the
        nearest millisecond.  Also changed str() to produce no more than
        three digits after the second's decimal point (if any).
    
        This ensures that DateTime->string->DateTime loses no information.
        Before this change, platform rounding errors in float<->string
        conversion could lose information in both conversion steps, so a
        DateTime object converted to string and back again didn't always
        reproduce the input object's value.  That's bad on its own, and
        testDateTime.py's testConstructor3() failed about 1% of the time
        on Linux as a result.  It doesn't fail after this patch.
    
        CAUTION:  Note that DateTime objects have at finest millisecond
        resolution now, even if the platform time.time() happens to have
        resolution finer than that.
    
    Note that he also had to fiddle with the function that returned system
    time, so he's got a wrapper around time.time() that rounds to 3 places
    the float returned by system time.   All the testing I've done
    indicates that this intermittent fixes the comparison failures.
    cc393366
DateTime.py 62.8 KB