• Victor Stinner's avatar
    Issue #23517: Fix rounding in fromtimestamp() and utcfromtimestamp() methods · 511491ad
    Victor Stinner yazdı
    of datetime.datetime: microseconds are now rounded to nearest with ties going
    to nearest even integer (ROUND_HALF_EVEN), instead of being rounding towards
    zero (ROUND_DOWN). It's important that these methods use the same rounding
    mode than datetime.timedelta to keep the property:
    
       (datetime(1970,1,1) + timedelta(seconds=t)) == datetime.utcfromtimestamp(t)
    
    It also the rounding mode used by round(float) for example.
    
    Add more unit tests on the rounding mode in test_datetime.
    511491ad
datetime.py 74 KB