Message249521
Ok, I fixed the issue in Python 3.6. Example with the initial message:
$ python2.7 -c 'import datetime; print(datetime.datetime.utcfromtimestamp(1424817268.274).microsecond); print(datetime.datetime.utcfromtimestamp(-1424817268.274).microsecond)'
274000
726000
$ python3.6 -c 'import datetime; print(datetime.datetime.utcfromtimestamp(1424817268.274).microsecond); print(datetime.datetime.utcfromtimestamp(-1424817268.274).microsecond)'
274000
726000
I wrote:
"On Python < 3.3, datetime.datetime.fromtimestamp(float) doesn't use exactly ROUND_HALF_EVEN, but it looks more to "round half away from zero" (the decimal module doesn't seem to support this exact rounding method)."
I was wrong: it's decimal.ROUND_HALF_UP in fact.
I will backport the change to Python 3.4 and 3.5. Since this issue was defined as a bugfix, it should be fixed in Python 3.5.1 (too late for 3.5.0). |
|
Date |
User |
Action |
Args |
2015-09-02 00:03:56 | vstinner | set | recipients:
+ vstinner, tim.peters, mark.dickinson, belopolsky, larry, r.david.murray, aconrad, vivanov, python-dev, tbarbugli, trcarden |
2015-09-02 00:03:56 | vstinner | set | messageid: <1441152236.04.0.614242392719.issue23517@psf.upfronthosting.co.za> |
2015-09-02 00:03:56 | vstinner | link | issue23517 messages |
2015-09-02 00:03:55 | vstinner | create | |
|