| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 69cc487 commit 7667f58
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,9 +31,9 @@ typedef enum { | |||
| 31 | 31 | /* Round towards infinity (+inf). | |
| 32 | 32 | For example, used for timeout to wait "at least" N seconds. */ | |
| 33 | 33 | _PyTime_ROUND_CEILING=1, | |
| 34 | - /* Round to nearest with ties going away from zero. | ||
| 34 | + /* Round to nearest with ties going to nearest even integer. | ||
| 35 | 35 | For example, used to round from a Python float. */ | |
| 36 | - _PyTime_ROUND_HALF_UP | ||
| 36 | + _PyTime_ROUND_HALF_EVEN | ||
| 37 | 37 | } _PyTime_round_t; | |
| 38 | 38 | ||
| 39 | 39 | /* Convert a time_t to a PyLong. */ | |
@@ -44,8 +44,9 @@ PyAPI_FUNC(PyObject *) _PyLong_FromTime_t( | |||
| 44 | 44 | PyAPI_FUNC(time_t) _PyLong_AsTime_t( | |
| 45 | 45 | PyObject *obj); | |
| 46 | 46 | ||
| 47 | - /* Round to nearest with ties going away from zero (_PyTime_ROUND_HALF_UP). */ | ||
| 48 | - PyAPI_FUNC(double) _PyTime_RoundHalfUp( | ||
| 47 | + /* Round to nearest with ties going to nearest even integer | ||
| 48 | + (_PyTime_ROUND_HALF_EVEN) */ | ||
| 49 | + PyAPI_FUNC(double) _PyTime_RoundHalfEven( | ||
| 49 | 50 | double x); | |
| 50 | 51 | ||
| 51 | 52 | /* Convert a number of seconds, int or float, to time_t. */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1380,7 +1380,7 @@ def _fromtimestamp(cls, t, utc, tz): | |||
| 1380 | 1380 | A timezone info object may be passed in as well. | |
| 1381 | 1381 | """ | |
| 1382 | 1382 | frac, t = _math.modf(t) | |
| 1383 | - us = _round_half_up(frac * 1e6) | ||
| 1383 | + us = round(frac * 1e6) | ||
| 1384 | 1384 | if us >= 1000000: | |
| 1385 | 1385 | t += 1 | |
| 1386 | 1386 | us -= 1000000 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1874,7 +1874,7 @@ def test_microsecond_rounding(self): | |||
| 1874 | 1874 | self.assertEqual(t, zero) | |
| 1875 | 1875 | t = fts(-1/2**7) | |
| 1876 | 1876 | self.assertEqual(t.second, 59) | |
| 1877 | - self.assertEqual(t.microsecond, 992187) | ||
| 1877 | + self.assertEqual(t.microsecond, 992188) | ||
| 1878 | 1878 | ||
| 1879 | 1879 | t = fts(1e-7) | |
| 1880 | 1880 | self.assertEqual(t, zero) | |
@@ -1888,7 +1888,7 @@ def test_microsecond_rounding(self): | |||
| 1888 | 1888 | self.assertEqual(t.microsecond, 0) | |
| 1889 | 1889 | t = fts(1/2**7) | |
| 1890 | 1890 | self.assertEqual(t.second, 0) | |
| 1891 | - self.assertEqual(t.microsecond, 7813) | ||
| 1891 | + self.assertEqual(t.microsecond, 7812) | ||
| 1892 | 1892 | ||
| 1893 | 1893 | def test_insane_fromtimestamp(self): | |
| 1894 | 1894 | # It's possible that some platform maps time_t to double, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments