| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -946,14 +946,14 @@ def test_milliseconds(self): | |||
| 946 | 946 | # nanoseconds | |
| 947 | 947 | (1, 0, FLOOR), | |
| 948 | 948 | (1, 1, CEILING), | |
| 949 | - (-1, 0, FLOOR), | ||
| 950 | - (-1, -1, CEILING), | ||
| 949 | + (-1, -1, FLOOR), | ||
| 950 | + (-1, 0, CEILING), | ||
| 951 | 951 | ||
| 952 | 952 | # seconds + nanoseconds | |
| 953 | 953 | (1234 * MS_TO_NS + 1, 1234, FLOOR), | |
| 954 | 954 | (1234 * MS_TO_NS + 1, 1235, CEILING), | |
| 955 | - (-1234 * MS_TO_NS - 1, -1234, FLOOR), | ||
| 956 | - (-1234 * MS_TO_NS - 1, -1235, CEILING), | ||
| 955 | + (-1234 * MS_TO_NS - 1, -1235, FLOOR), | ||
| 956 | + (-1234 * MS_TO_NS - 1, -1234, CEILING), | ||
| 957 | 957 | ): | |
| 958 | 958 | with self.subTest(nanoseconds=ns, milliseconds=ms, round=rnd): | |
| 959 | 959 | self.assertEqual(PyTime_AsMilliseconds(ns, rnd), ms) | |
@@ -983,14 +983,14 @@ def test_microseconds(self): | |||
| 983 | 983 | # nanoseconds | |
| 984 | 984 | (1, 0, FLOOR), | |
| 985 | 985 | (1, 1, CEILING), | |
| 986 | - (-1, 0, FLOOR), | ||
| 987 | - (-1, -1, CEILING), | ||
| 986 | + (-1, -1, FLOOR), | ||
| 987 | + (-1, 0, CEILING), | ||
| 988 | 988 | ||
| 989 | 989 | # seconds + nanoseconds | |
| 990 | 990 | (1234 * US_TO_NS + 1, 1234, FLOOR), | |
| 991 | 991 | (1234 * US_TO_NS + 1, 1235, CEILING), | |
| 992 | - (-1234 * US_TO_NS - 1, -1234, FLOOR), | ||
| 993 | - (-1234 * US_TO_NS - 1, -1235, CEILING), | ||
| 992 | + (-1234 * US_TO_NS - 1, -1235, FLOOR), | ||
| 993 | + (-1234 * US_TO_NS - 1, -1234, CEILING), | ||
| 994 | 994 | ): | |
| 995 | 995 | with self.subTest(nanoseconds=ns, milliseconds=ms, round=rnd): | |
| 996 | 996 | self.assertEqual(PyTime_AsMicroseconds(ns, rnd), ms) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -305,17 +305,22 @@ _PyTime_AsNanosecondsObject(_PyTime_t t) | |||
| 305 | 305 | } | |
| 306 | 306 | ||
| 307 | 307 | static _PyTime_t | |
| 308 | - _PyTime_Divide(_PyTime_t t, _PyTime_t k, _PyTime_round_t round) | ||
| 308 | + _PyTime_Divide(const _PyTime_t t, const _PyTime_t k, | ||
| 309 | + const _PyTime_round_t round) | ||
| 309 | 310 | { | |
| 310 | 311 | assert(k > 1); | |
| 311 | 312 | if (round == _PyTime_ROUND_CEILING) { | |
| 312 | 313 | if (t >= 0) | |
| 313 | 314 | return (t + k - 1) / k; | |
| 315 | + else | ||
| 316 | + return t / k; | ||
| 317 | + } | ||
| 318 | + else { | ||
| 319 | + if (t >= 0) | ||
| 320 | + return t / k; | ||
| 314 | 321 | else | |
| 315 | 322 | return (t - (k - 1)) / k; | |
| 316 | 323 | } | |
| 317 | - else | ||
| 318 | - return t / k; | ||
| 319 | 324 | } | |
| 320 | 325 | ||
| 321 | 326 | _PyTime_t | |
| Back | FazBrowse Home | New Git URL |
0 commit comments