Skip to content

Commit

Permalink
pythongh-120713: use "%04ld" instead of "%04d" to avoid unnecessary i…
Browse files Browse the repository at this point in the history
…nt conversion
  • Loading branch information
blhsing committed Jun 24, 2024
1 parent 2c3252f commit 9fd3d2d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1942,13 +1942,10 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
#ifdef NORMALIZE_CENTURY
else if (ch == 'Y') {
/* 0-pad year with century on platforms that do not do so */
PyObject *year = PyObject_GetAttrString(object, "year");
if (year == NULL)
goto Done;
char formatted[5];
ntoappend = sprintf(formatted, "%04d", (int)PyLong_AsLong(year));
ntoappend = sprintf(formatted, "%04ld",
PyLong_AsLong(PyTuple_GET_ITEM(timetuple, 0)));
ptoappend = formatted;
Py_DECREF(year);
}
#endif
else {
Expand Down

0 comments on commit 9fd3d2d

Please sign in to comment.