mirror of
https://github.com/python/cpython.git
synced 2025-07-07 11:25:30 +00:00
gh-88994: Change datetime.datetime.now
to half-even rounding (#134258)
Change `datetime.datetime.now` to half-even rounding for consistency with `datetime.fromtimestamp`.
This commit is contained in:
parent
42d03f3933
commit
470941782f
3 changed files with 6 additions and 1 deletions
|
@ -795,6 +795,7 @@ Albert Hofkamp
|
|||
Chris Hogan
|
||||
Tomas Hoger
|
||||
Jonathan Hogg
|
||||
John Keith Hohm
|
||||
Vladyslav Hoi
|
||||
Kamilla Holanda
|
||||
Steve Holden
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Change :func:`datetime.datetime.now` to half-even rounding for
|
||||
consistency with :func:`datetime.datetime.fromtimestamp`. Patch by
|
||||
John Keith Hohm.
|
|
@ -5551,8 +5551,9 @@ datetime_best_possible(PyObject *cls, TM_FUNC f, PyObject *tzinfo)
|
|||
time_t secs;
|
||||
int us;
|
||||
|
||||
if (_PyTime_AsTimevalTime_t(ts, &secs, &us, _PyTime_ROUND_FLOOR) < 0)
|
||||
if (_PyTime_AsTimevalTime_t(ts, &secs, &us, _PyTime_ROUND_HALF_EVEN) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
assert(0 <= us && us <= 999999);
|
||||
|
||||
return datetime_from_timet_and_us(cls, f, secs, us, tzinfo);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue