From 9d3d701c089ebcaa556db2a2fb23c34196f72fe4 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Tue, 28 Oct 2025 18:24:19 +0000 Subject: [PATCH 1/4] Commit --- Doc/library/datetime.rst | 265 ++++++++++++++++++++++----------------- 1 file changed, 150 insertions(+), 115 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 8ae1c1fb9e46bb..50c2d8c71be574 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2495,108 +2495,153 @@ These methods accept format codes that can be used to parse and format dates:: >>> _.strftime('%a %d %b %Y, %I:%M%p') 'Mon 31 Jan 2022, 11:59PM' -The following is a list of all the format codes that the 1989 C standard -requires, and these work on all platforms with a standard C implementation. - -+-----------+--------------------------------+------------------------+-------+ -| Directive | Meaning | Example | Notes | -+===========+================================+========================+=======+ -| ``%a`` | Weekday as locale's || Sun, Mon, ..., Sat | \(1) | -| | abbreviated name. | (en_US); | | -| | || So, Mo, ..., Sa | | -| | | (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%A`` | Weekday as locale's full name. || Sunday, Monday, ..., | \(1) | -| | | Saturday (en_US); | | -| | || Sonntag, Montag, ..., | | -| | | Samstag (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%w`` | Weekday as a decimal number, | 0, 1, ..., 6 | | -| | where 0 is Sunday and 6 is | | | -| | Saturday. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%d`` | Day of the month as a | 01, 02, ..., 31 | \(9) | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%b`` | Month as locale's abbreviated || Jan, Feb, ..., Dec | \(1) | -| | name. | (en_US); | | -| | || Jan, Feb, ..., Dez | | -| | | (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%B`` | Month as locale's full name. || January, February, | \(1) | -| | | ..., December (en_US);| | -| | || Januar, Februar, ..., | | -| | | Dezember (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%m`` | Month as a zero-padded | 01, 02, ..., 12 | \(9) | -| | decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%y`` | Year without century as a | 00, 01, ..., 99 | \(9) | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%Y`` | Year with century as a decimal | 0001, 0002, ..., 2013, | \(2) | -| | number. | 2014, ..., 9998, 9999 | | -+-----------+--------------------------------+------------------------+-------+ -| ``%H`` | Hour (24-hour clock) as a | 00, 01, ..., 23 | \(9) | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%I`` | Hour (12-hour clock) as a | 01, 02, ..., 12 | \(9) | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%p`` | Locale's equivalent of either || AM, PM (en_US); | \(1), | -| | AM or PM. || am, pm (de_DE) | \(3) | -+-----------+--------------------------------+------------------------+-------+ -| ``%M`` | Minute as a zero-padded | 00, 01, ..., 59 | \(9) | -| | decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | \(4), | -| | decimal number. | | \(9) | -+-----------+--------------------------------+------------------------+-------+ -| ``%f`` | Microsecond as a decimal | 000000, 000001, ..., | \(5) | -| | number, zero-padded to 6 | 999999 | | -| | digits. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%z`` | UTC offset in the form | (empty), +0000, | \(6) | -| | ``±HHMM[SS[.ffffff]]`` (empty | -0400, +1030, | | -| | string if the object is | +063415, | | -| | naive). | -030712.345216 | | -+-----------+--------------------------------+------------------------+-------+ -| ``%Z`` | Time zone name (empty string | (empty), UTC, GMT | \(6) | -| | if the object is naive). | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%j`` | Day of the year as a | 001, 002, ..., 366 | \(9) | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%U`` | Week number of the year | 00, 01, ..., 53 | \(7), | -| | (Sunday as the first day of | | \(9) | -| | the week) as a zero-padded | | | -| | decimal number. All days in a | | | -| | new year preceding the first | | | -| | Sunday are considered to be in | | | -| | week 0. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%W`` | Week number of the year | 00, 01, ..., 53 | \(7), | -| | (Monday as the first day of | | \(9) | -| | the week) as a zero-padded | | | -| | decimal number. All days in a | | | -| | new year preceding the first | | | -| | Monday are considered to be in | | | -| | week 0. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%c`` | Locale's appropriate date and || Tue Aug 16 21:30:00 | \(1) | -| | time representation. | 1988 (en_US); | | -| | || Di 16 Aug 21:30:00 | | -| | | 1988 (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%x`` | Locale's appropriate date || 08/16/88 (None); | \(1) | -| | representation. || 08/16/1988 (en_US); | | -| | || 16.08.1988 (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%X`` | Locale's appropriate time || 21:30:00 (en_US); | \(1) | -| | representation. || 21:30:00 (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%%`` | A literal ``'%'`` character. | % | | -+-----------+--------------------------------+------------------------+-------+ +The following is a list of all the format codes that the 2011 C standard +requires, and these work on all supported platforms. + ++-----------+--------------------------------+------------------------+--------------+-------+ +| Directive | Meaning | Example | ``strptime`` | Notes | +| | | | support? | | ++===========+================================+========================+==============+=======+ +| ``%a`` | Weekday as locale's || Sun, Mon, ..., Sat | Yes | \(1) | +| | abbreviated name. | (en_US); | | | +| | || So, Mo, ..., Sa | | | +| | | (de_DE) | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%A`` | Weekday as locale's full name. || Sunday, Monday, ..., | Yes | \(1) | +| | | Saturday (en_US); | | | +| | || Sonntag, Montag, ..., | | | +| | | Samstag (de_DE) | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%b`` | Month as locale's abbreviated || Jan, Feb, ..., Dec | Yes | \(1) | +| | name. | (en_US); | | | +| | || Jan, Feb, ..., Dez | | | +| | | (de_DE) | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%B`` | Month as locale's full name. || January, February, | Yes | \(1) | +| | | ..., December (en_US);| | | +| | || Januar, Februar, ..., | | | +| | | Dezember (de_DE) | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%c`` | Locale's appropriate date and || Tue Aug 16 21:30:00 | Yes | \(1) | +| | time representation. | 1988 (en_US); | | | +| | || Di 16 Aug 21:30:00 | | | +| | | 1988 (de_DE) | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%C`` | The year divided by 100 and | 01, 02, ..., 99 | No | | +| | truncated to an integer as a | | | | +| | zero-padded decimal number. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%d`` | Day of the month as a | 01, 02, ..., 31 | Yes | \(9) | +| | zero-padded decimal number. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%D`` | Equivalent to ``%m/%d/%y``. | 11/10/2025 | No | \(9) | +| | | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%e`` | The day of the month as a | `` 1``, `` 2``, ..., | No | | +| | space-padded decimal number. | ``31`` | | | +| | | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | No | | +| | the ISO 8601 format. | 1001-12-30 | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%g`` | Last 2 digits of ISO 8601 year | 00, 01, ..., 99 | No | | +| | representing the year that | | | | +| | contains the greater part of | | | | +| | the ISO week (``%V``). | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%G`` | ISO 8601 year with century | 0001, 0002, ..., 2013, | Yes | \(8) | +| | representing the year that | 2014, ..., 9998, 9999 | | | +| | contains the greater part of | | | | +| | the ISO week (``%V``). | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%h`` | Equivalent to ``%b``. | See ``%b``. | No | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%H`` | Hour (24-hour clock) as a | 00, 01, ..., 23 | Yes | \(9) | +| | zero-padded decimal number. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%I`` | Hour (12-hour clock) as a | 01, 02, ..., 12 | Yes | \(9) | +| | zero-padded decimal number. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%j`` | Day of the year as a | 001, 002, ..., 366 | Yes | \(9) | +| | zero-padded decimal number. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%m`` | Month as a zero-padded | 01, 02, ..., 12 | Yes | \(9) | +| | decimal number. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%M`` | Minute as a zero-padded | 00, 01, ..., 59 | Yes | \(9) | +| | decimal number. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%n`` | The newline character | ``\n`` | No | | +| | (``'\n'``). | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%p`` | Locale's equivalent of either || AM, PM (en_US); | Yes | \(1), | +| | AM or PM. || am, pm (de_DE) | | \(3) | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%r`` | Locale's 12-hour clock time. | 12:00:00 AM | No | \(1) | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%R`` | Equivalent to ``%H:%M``. | 10:01 | Yes | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | Yes | \(4), | +| | decimal number. | | | \(9) | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%t`` | The tab character | ``\t`` | No | | +| | (``'\t'``). | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%T`` | ISO 8601 time format, | 10:01:59 | Yes | | +| | equivalent to ``%H:%M:%S``. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%u`` | ISO 8601 weekday as a decimal | 1, 2, ..., 7 | Yes | | +| | number where 1 is Monday. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%U`` | Week number of the year | 00, 01, ..., 53 | Yes | \(7), | +| | (Sunday as the first day of | | | \(9) | +| | the week) as a zero-padded | | | | +| | decimal number. All days in a | | | | +| | new year preceding the first | | | | +| | Sunday are considered to be in | | | | +| | week 0. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%V`` | ISO 8601 week as a decimal | 01, 02, ..., 53 | Yes | \(8), | +| | number with Monday as | | | \(9) | +| | the first day of the week. | | | | +| | Week 01 is the week containing | | | | +| | Jan 4. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%w`` | Weekday as a decimal number, | 0, 1, ..., 6 | Yes | | +| | where 0 is Sunday and 6 is | | | | +| | Saturday. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%W`` | Week number of the year | 00, 01, ..., 53 | Yes | \(7), | +| | (Monday as the first day of | | | \(9) | +| | the week) as a zero-padded | | | | +| | decimal number. All days in a | | | | +| | new year preceding the first | | | | +| | Monday are considered to be in | | | | +| | week 0. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%x`` | Locale's appropriate date || 08/16/88 (None); | Yes | \(1) | +| | representation. || 08/16/1988 (en_US); | | | +| | || 16.08.1988 (de_DE) | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%X`` | Locale's appropriate time || 21:30:00 (en_US); | Yes | \(1) | +| | representation. || 21:30:00 (de_DE) | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%y`` | Year without century as a | 00, 01, ..., 99 | Yes | \(9) | +| | zero-padded decimal number. | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%Y`` | Year with century as a decimal | 0001, 0002, ..., 2013, | Yes | \(2) | +| | number. | 2014, ..., 9998, 9999 | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%z`` | UTC offset in the form | (empty), +0000, | Yes | \(6) | +| | ``±HHMM[SS[.ffffff]]`` (empty | -0400, +1030, | | | +| | string if the object is | +063415, | | | +| | naive). | -030712.345216 | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%Z`` | Time zone name (empty string | (empty), UTC, GMT | Yes | \(6) | +| | if the object is naive). | | | | ++-----------+--------------------------------+------------------------+--------------+-------+ +| ``%%`` | A literal ``'%'`` character. | % | Yes | | ++-----------+--------------------------------+------------------------+--------------+-------+ Several additional directives not required by the C89 standard are included for convenience. These parameters all correspond to ISO 8601 date values. @@ -2604,19 +2649,9 @@ convenience. These parameters all correspond to ISO 8601 date values. +-----------+--------------------------------+------------------------+-------+ | Directive | Meaning | Example | Notes | +===========+================================+========================+=======+ -| ``%G`` | ISO 8601 year with century | 0001, 0002, ..., 2013, | \(8) | -| | representing the year that | 2014, ..., 9998, 9999 | | -| | contains the greater part of | | | -| | the ISO week (``%V``). | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%u`` | ISO 8601 weekday as a decimal | 1, 2, ..., 7 | | -| | number where 1 is Monday. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%V`` | ISO 8601 week as a decimal | 01, 02, ..., 53 | \(8), | -| | number with Monday as | | \(9) | -| | the first day of the week. | | | -| | Week 01 is the week containing | | | -| | Jan 4. | | | +| ``%f`` | Microsecond as a decimal | 000000, 000001, ..., | \(5) | +| | number, zero-padded to 6 | 999999 | | +| | digits. | | | +-----------+--------------------------------+------------------------+-------+ | ``%:z`` | UTC offset in the form | (empty), +00:00, | \(6) | | | ``±HH:MM[:SS[.ffffff]]`` | -04:00, +10:30, | | From d4cfe404779ffd3c9cc76ec247d76ccf9743ce7a Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Tue, 28 Oct 2025 18:29:49 +0000 Subject: [PATCH 2/4] Move text around --- Doc/library/datetime.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 50c2d8c71be574..a19849070b0449 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2643,8 +2643,12 @@ requires, and these work on all supported platforms. | ``%%`` | A literal ``'%'`` character. | % | Yes | | +-----------+--------------------------------+------------------------+--------------+-------+ -Several additional directives not required by the C89 standard are included for -convenience. These parameters all correspond to ISO 8601 date values. +The ISO 8601 year and ISO 8601 week directives are not interchangeable +with the year and week number directives above. Calling :meth:`~.datetime.strptime` with +incomplete or ambiguous ISO 8601 directives will raise a :exc:`ValueError`. + +Several additional directives not required by the C11 standard are included for +convenience. +-----------+--------------------------------+------------------------+-------+ | Directive | Meaning | Example | Notes | @@ -2659,11 +2663,6 @@ convenience. These parameters all correspond to ISO 8601 date values. | | naive). | -03:07:12.345216 | | +-----------+--------------------------------+------------------------+-------+ -These may not be available on all platforms when used with the :meth:`~.datetime.strftime` -method. The ISO 8601 year and ISO 8601 week directives are not interchangeable -with the year and week number directives above. Calling :meth:`~.datetime.strptime` with -incomplete or ambiguous ISO 8601 directives will raise a :exc:`ValueError`. - The full set of format codes supported varies across platforms, because Python calls the platform C library's :c:func:`strftime` function, and platform variations are common. To see the full set of format codes supported on your From 3fdd195b8ee7b302920154439dcd583c6bdde7dc Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 30 Oct 2025 10:04:05 +0000 Subject: [PATCH 3/4] Fix example --- Doc/library/datetime.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index a19849070b0449..31dde953edc09f 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2537,9 +2537,8 @@ requires, and these work on all supported platforms. | ``%D`` | Equivalent to ``%m/%d/%y``. | 11/10/2025 | No | \(9) | | | | | | | +-----------+--------------------------------+------------------------+--------------+-------+ -| ``%e`` | The day of the month as a | `` 1``, `` 2``, ..., | No | | -| | space-padded decimal number. | ``31`` | | | -| | | | | | +| ``%e`` | The day of the month as a | ``␣1``, ..., ``31`` | No | | +| | space-padded decimal number. | | | | +-----------+--------------------------------+------------------------+--------------+-------+ | ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | No | | | | the ISO 8601 format. | 1001-12-30 | | | From b2e3763e70834118408b1df78bc5f7bcc6381a30 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 30 Oct 2025 14:01:31 +0000 Subject: [PATCH 4/4] Replace with footnote --- Doc/library/datetime.rst | 290 ++++++++++++++++++++------------------- 1 file changed, 147 insertions(+), 143 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 31dde953edc09f..0a4f8c8a339bed 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2498,149 +2498,150 @@ These methods accept format codes that can be used to parse and format dates:: The following is a list of all the format codes that the 2011 C standard requires, and these work on all supported platforms. -+-----------+--------------------------------+------------------------+--------------+-------+ -| Directive | Meaning | Example | ``strptime`` | Notes | -| | | | support? | | -+===========+================================+========================+==============+=======+ -| ``%a`` | Weekday as locale's || Sun, Mon, ..., Sat | Yes | \(1) | -| | abbreviated name. | (en_US); | | | -| | || So, Mo, ..., Sa | | | -| | | (de_DE) | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%A`` | Weekday as locale's full name. || Sunday, Monday, ..., | Yes | \(1) | -| | | Saturday (en_US); | | | -| | || Sonntag, Montag, ..., | | | -| | | Samstag (de_DE) | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%b`` | Month as locale's abbreviated || Jan, Feb, ..., Dec | Yes | \(1) | -| | name. | (en_US); | | | -| | || Jan, Feb, ..., Dez | | | -| | | (de_DE) | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%B`` | Month as locale's full name. || January, February, | Yes | \(1) | -| | | ..., December (en_US);| | | -| | || Januar, Februar, ..., | | | -| | | Dezember (de_DE) | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%c`` | Locale's appropriate date and || Tue Aug 16 21:30:00 | Yes | \(1) | -| | time representation. | 1988 (en_US); | | | -| | || Di 16 Aug 21:30:00 | | | -| | | 1988 (de_DE) | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%C`` | The year divided by 100 and | 01, 02, ..., 99 | No | | -| | truncated to an integer as a | | | | -| | zero-padded decimal number. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%d`` | Day of the month as a | 01, 02, ..., 31 | Yes | \(9) | -| | zero-padded decimal number. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%D`` | Equivalent to ``%m/%d/%y``. | 11/10/2025 | No | \(9) | -| | | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%e`` | The day of the month as a | ``␣1``, ..., ``31`` | No | | -| | space-padded decimal number. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | No | | -| | the ISO 8601 format. | 1001-12-30 | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%g`` | Last 2 digits of ISO 8601 year | 00, 01, ..., 99 | No | | -| | representing the year that | | | | -| | contains the greater part of | | | | -| | the ISO week (``%V``). | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%G`` | ISO 8601 year with century | 0001, 0002, ..., 2013, | Yes | \(8) | -| | representing the year that | 2014, ..., 9998, 9999 | | | -| | contains the greater part of | | | | -| | the ISO week (``%V``). | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%h`` | Equivalent to ``%b``. | See ``%b``. | No | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%H`` | Hour (24-hour clock) as a | 00, 01, ..., 23 | Yes | \(9) | -| | zero-padded decimal number. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%I`` | Hour (12-hour clock) as a | 01, 02, ..., 12 | Yes | \(9) | -| | zero-padded decimal number. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%j`` | Day of the year as a | 001, 002, ..., 366 | Yes | \(9) | -| | zero-padded decimal number. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%m`` | Month as a zero-padded | 01, 02, ..., 12 | Yes | \(9) | -| | decimal number. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%M`` | Minute as a zero-padded | 00, 01, ..., 59 | Yes | \(9) | -| | decimal number. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%n`` | The newline character | ``\n`` | No | | -| | (``'\n'``). | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%p`` | Locale's equivalent of either || AM, PM (en_US); | Yes | \(1), | -| | AM or PM. || am, pm (de_DE) | | \(3) | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%r`` | Locale's 12-hour clock time. | 12:00:00 AM | No | \(1) | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%R`` | Equivalent to ``%H:%M``. | 10:01 | Yes | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | Yes | \(4), | -| | decimal number. | | | \(9) | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%t`` | The tab character | ``\t`` | No | | -| | (``'\t'``). | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%T`` | ISO 8601 time format, | 10:01:59 | Yes | | -| | equivalent to ``%H:%M:%S``. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%u`` | ISO 8601 weekday as a decimal | 1, 2, ..., 7 | Yes | | -| | number where 1 is Monday. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%U`` | Week number of the year | 00, 01, ..., 53 | Yes | \(7), | -| | (Sunday as the first day of | | | \(9) | -| | the week) as a zero-padded | | | | -| | decimal number. All days in a | | | | -| | new year preceding the first | | | | -| | Sunday are considered to be in | | | | -| | week 0. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%V`` | ISO 8601 week as a decimal | 01, 02, ..., 53 | Yes | \(8), | -| | number with Monday as | | | \(9) | -| | the first day of the week. | | | | -| | Week 01 is the week containing | | | | -| | Jan 4. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%w`` | Weekday as a decimal number, | 0, 1, ..., 6 | Yes | | -| | where 0 is Sunday and 6 is | | | | -| | Saturday. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%W`` | Week number of the year | 00, 01, ..., 53 | Yes | \(7), | -| | (Monday as the first day of | | | \(9) | -| | the week) as a zero-padded | | | | -| | decimal number. All days in a | | | | -| | new year preceding the first | | | | -| | Monday are considered to be in | | | | -| | week 0. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%x`` | Locale's appropriate date || 08/16/88 (None); | Yes | \(1) | -| | representation. || 08/16/1988 (en_US); | | | -| | || 16.08.1988 (de_DE) | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%X`` | Locale's appropriate time || 21:30:00 (en_US); | Yes | \(1) | -| | representation. || 21:30:00 (de_DE) | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%y`` | Year without century as a | 00, 01, ..., 99 | Yes | \(9) | -| | zero-padded decimal number. | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%Y`` | Year with century as a decimal | 0001, 0002, ..., 2013, | Yes | \(2) | -| | number. | 2014, ..., 9998, 9999 | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%z`` | UTC offset in the form | (empty), +0000, | Yes | \(6) | -| | ``±HHMM[SS[.ffffff]]`` (empty | -0400, +1030, | | | -| | string if the object is | +063415, | | | -| | naive). | -030712.345216 | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%Z`` | Time zone name (empty string | (empty), UTC, GMT | Yes | \(6) | -| | if the object is naive). | | | | -+-----------+--------------------------------+------------------------+--------------+-------+ -| ``%%`` | A literal ``'%'`` character. | % | Yes | | -+-----------+--------------------------------+------------------------+--------------+-------+ ++-----------+--------------------------------+------------------------+-------+ +| Directive | Meaning | Example | Notes | +| | | | | ++===========+================================+========================+=======+ +| ``%a`` | Weekday as locale's || Sun, Mon, ..., Sat | \(1) | +| | abbreviated name. | (en_US); | | +| | || So, Mo, ..., Sa | | +| | | (de_DE) | | ++-----------+--------------------------------+------------------------+-------+ +| ``%A`` | Weekday as locale's full name. || Sunday, Monday, ..., | \(1) | +| | | Saturday (en_US); | | +| | || Sonntag, Montag, ..., | | +| | | Samstag (de_DE) | | ++-----------+--------------------------------+------------------------+-------+ +| ``%b`` | Month as locale's abbreviated || Jan, Feb, ..., Dec | \(1) | +| | name. | (en_US); | | +| | || Jan, Feb, ..., Dez | | +| | | (de_DE) | | ++-----------+--------------------------------+------------------------+-------+ +| ``%B`` | Month as locale's full name. || January, February, | \(1) | +| | | ..., December (en_US);| | +| | || Januar, Februar, ..., | | +| | | Dezember (de_DE) | | ++-----------+--------------------------------+------------------------+-------+ +| ``%c`` | Locale's appropriate date and || Tue Aug 16 21:30:00 | \(1) | +| | time representation. | 1988 (en_US); | | +| | || Di 16 Aug 21:30:00 | | +| | | 1988 (de_DE) | | ++-----------+--------------------------------+------------------------+-------+ +| ``%C`` | The year divided by 100 and | 01, 02, ..., 99 | \(0) | +| | truncated to an integer as a | | | +| | zero-padded decimal number. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%d`` | Day of the month as a | 01, 02, ..., 31 | \(9) | +| | zero-padded decimal number. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%D`` | Equivalent to ``%m/%d/%y``. | 11/10/2025 | \(9), | +| | | | \(0) | ++-----------+--------------------------------+------------------------+-------+ +| ``%e`` | The day of the month as a | ``␣1``, ..., ``31`` | | +| | space-padded decimal number. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | \(0) | +| | the ISO 8601 format. | 1001-12-30 | | ++-----------+--------------------------------+------------------------+-------+ +| ``%g`` | Last 2 digits of ISO 8601 year | 00, 01, ..., 99 | \(0) | +| | representing the year that | | | +| | contains the greater part of | | | +| | the ISO week (``%V``). | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%G`` | ISO 8601 year with century | 0001, 0002, ..., 2013, | \(8) | +| | representing the year that | 2014, ..., 9998, 9999 | | +| | contains the greater part of | | | +| | the ISO week (``%V``). | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%h`` | Equivalent to ``%b``. | See ``%b``. | \(0) | ++-----------+--------------------------------+------------------------+-------+ +| ``%H`` | Hour (24-hour clock) as a | 00, 01, ..., 23 | \(9) | +| | zero-padded decimal number. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%I`` | Hour (12-hour clock) as a | 01, 02, ..., 12 | \(9) | +| | zero-padded decimal number. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%j`` | Day of the year as a | 001, 002, ..., 366 | \(9) | +| | zero-padded decimal number. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%m`` | Month as a zero-padded | 01, 02, ..., 12 | \(9) | +| | decimal number. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%M`` | Minute as a zero-padded | 00, 01, ..., 59 | \(9) | +| | decimal number. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%n`` | The newline character | ``\n`` | \(0) | +| | (``'\n'``). | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%p`` | Locale's equivalent of either || AM, PM (en_US); | \(1), | +| | AM or PM. || am, pm (de_DE) | \(3) | ++-----------+--------------------------------+------------------------+-------+ +| ``%r`` | Locale's 12-hour clock time. | 12:00:00 AM | \(1), | +| | | | \(0) | ++-----------+--------------------------------+------------------------+-------+ +| ``%R`` | Equivalent to ``%H:%M``. | 10:01 | | ++-----------+--------------------------------+------------------------+-------+ +| ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | \(4), | +| | decimal number. | | \(9) | ++-----------+--------------------------------+------------------------+-------+ +| ``%t`` | The tab character | ``\t`` | \(0) | +| | (``'\t'``). | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%T`` | ISO 8601 time format, | 10:01:59 | | +| | equivalent to ``%H:%M:%S``. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%u`` | ISO 8601 weekday as a decimal | 1, 2, ..., 7 | | +| | number where 1 is Monday. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%U`` | Week number of the year | 00, 01, ..., 53 | \(7), | +| | (Sunday as the first day of | | \(9) | +| | the week) as a zero-padded | | | +| | decimal number. All days in a | | | +| | new year preceding the first | | | +| | Sunday are considered to be in | | | +| | week 0. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%V`` | ISO 8601 week as a decimal | 01, 02, ..., 53 | \(8), | +| | number with Monday as | | \(9) | +| | the first day of the week. | | | +| | Week 01 is the week containing | | | +| | Jan 4. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%w`` | Weekday as a decimal number, | 0, 1, ..., 6 | | +| | where 0 is Sunday and 6 is | | | +| | Saturday. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%W`` | Week number of the year | 00, 01, ..., 53 | \(7), | +| | (Monday as the first day of | | \(9) | +| | the week) as a zero-padded | | | +| | decimal number. All days in a | | | +| | new year preceding the first | | | +| | Monday are considered to be in | | | +| | week 0. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%x`` | Locale's appropriate date || 08/16/88 (None); | \(1) | +| | representation. || 08/16/1988 (en_US); | | +| | || 16.08.1988 (de_DE) | | ++-----------+--------------------------------+------------------------+-------+ +| ``%X`` | Locale's appropriate time || 21:30:00 (en_US); | \(1) | +| | representation. || 21:30:00 (de_DE) | | ++-----------+--------------------------------+------------------------+-------+ +| ``%y`` | Year without century as a | 00, 01, ..., 99 | \(9) | +| | zero-padded decimal number. | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%Y`` | Year with century as a decimal | 0001, 0002, ..., 2013, | \(2) | +| | number. | 2014, ..., 9998, 9999 | | ++-----------+--------------------------------+------------------------+-------+ +| ``%z`` | UTC offset in the form | (empty), +0000, | \(6) | +| | ``±HHMM[SS[.ffffff]]`` (empty | -0400, +1030, | | +| | string if the object is | +063415, | | +| | naive). | -030712.345216 | | ++-----------+--------------------------------+------------------------+-------+ +| ``%Z`` | Time zone name (empty string | (empty), UTC, GMT | \(6) | +| | if the object is naive). | | | ++-----------+--------------------------------+------------------------+-------+ +| ``%%`` | A literal ``'%'`` character. | % | | ++-----------+--------------------------------+------------------------+-------+ The ISO 8601 year and ISO 8601 week directives are not interchangeable with the year and week number directives above. Calling :meth:`~.datetime.strptime` with @@ -2712,6 +2713,9 @@ an empty string instead. Notes: +(0) + This format code is currently unsupported by :meth:`~.datetime.strptime`. + (1) Because the format depends on the current locale, care should be taken when making assumptions about the output value. Field orderings will vary (for