Skip to content

Commit ddc75ed

Browse files
author
marat
committed
Unify strftime/ptime notes and refactor code
1 parent 551f16e commit ddc75ed

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Doc/library/datetime.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,17 +2762,16 @@ Notes:
27622762
interchangeable.
27632763

27642764
(9)
2765-
When used with the :meth:`~.datetime.strftime` method, the leading zero is optional
2766-
for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, ``%j``, ``%U``,
2767-
``%W``, ``%V`` and ``%y`` (except that on Apple platforms, ``%y`` always produces
2768-
a leading zero). Use the ``%-`` flag to produce non-zero-padded output
2769-
(for example, ``%-d``).
2770-
2771-
(10)
27722765
When used with the :meth:`~.datetime.strptime` method, the leading zero is optional
27732766
for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, ``%j``, ``%U``,
27742767
``%W``, and ``%V``. Format ``%y`` does require a leading zero.
27752768

2769+
When used with the :meth:`~.datetime.strftime` method, the leading zero is optional
2770+
for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, ``%j``, ``%U``,
2771+
``%W``, ``%V`` and ``%y``. The ``%-`` flag (for example, ``%-d``) will produce
2772+
non-zero-padded output, except for ``%-y`` on Apple platforms, which is still
2773+
zero-padded.
2774+
27762775
(11)
27772776
When parsing a month and day using :meth:`~.datetime.strptime`, always
27782777
include a year in the format. If the value you need to parse lacks a year,

Lib/_pydatetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def _wrap_strftime(object, format, timetuple):
293293
if i < n:
294294
next_ch = format[i]
295295
i += 1
296-
if sys.platform.startswith('win') or sys.platform.startswith('android'):
296+
if sys.platform in ['win32', 'android']:
297297
push(_make_dash_replacement(next_ch, timetuple))
298298
else:
299299
push('%-' + next_ch)

0 commit comments

Comments
 (0)