mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #23517: fromtimestamp() and utcfromtimestamp() methods of
datetime.datetime now round microseconds to nearest with ties going to nearest even integer (ROUND_HALF_EVEN), as round(float), instead of rounding towards -Infinity (ROUND_FLOOR). pytime API: replace _PyTime_ROUND_HALF_UP with _PyTime_ROUND_HALF_EVEN. Fix also _PyTime_Divide() for negative numbers. _PyTime_AsTimeval_impl() now reuses _PyTime_Divide() instead of reimplementing rounding modes.
This commit is contained in:
parent
69cc487df4
commit
7667f58151
8 changed files with 148 additions and 185 deletions
|
@ -1874,7 +1874,7 @@ class TestDateTime(TestDate):
|
|||
self.assertEqual(t, zero)
|
||||
t = fts(-1/2**7)
|
||||
self.assertEqual(t.second, 59)
|
||||
self.assertEqual(t.microsecond, 992187)
|
||||
self.assertEqual(t.microsecond, 992188)
|
||||
|
||||
t = fts(1e-7)
|
||||
self.assertEqual(t, zero)
|
||||
|
@ -1888,7 +1888,7 @@ class TestDateTime(TestDate):
|
|||
self.assertEqual(t.microsecond, 0)
|
||||
t = fts(1/2**7)
|
||||
self.assertEqual(t.second, 0)
|
||||
self.assertEqual(t.microsecond, 7813)
|
||||
self.assertEqual(t.microsecond, 7812)
|
||||
|
||||
def test_insane_fromtimestamp(self):
|
||||
# It's possible that some platform maps time_t to double,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue