Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ Albert Hofkamp
Chris Hogan
Tomas Hoger
Jonathan Hogg
John Keith Hohm
Vladyslav Hoi
Kamilla Holanda
Steve Holden
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 2 additions & 1 deletion Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5539,8 +5539,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);
Expand Down
Loading