From fa96d69dc064eb6d226a4773f270a88f82b4508c Mon Sep 17 00:00:00 2001 From: Gus Goulart Date: Fri, 19 Oct 2018 22:31:46 -0300 Subject: [PATCH 1/4] Better wording for datetime.strptime() --- Doc/library/datetime.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 7a276b139f5eca..48fcc3de65c18a 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2013,7 +2013,8 @@ although not all objects support a :meth:`timetuple` method. Conversely, the :meth:`datetime.strptime` class method creates a :class:`.datetime` object from a string representing a date and time and a corresponding format string. ``datetime.strptime(date_string, format)`` is -equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``. +similar to ``datetime(*(time.strptime(date_string, format)[0:6]))``, however, +``datetime.strptime()`` also retains both microseconds and timezone data. For :class:`.time` objects, the format codes for year, month, and day should not be used, as time objects have no such values. If they're used anyway, ``1900`` From e1c17e7b3125d54809e507eae6d3664453660a26 Mon Sep 17 00:00:00 2001 From: Gus Goulart Date: Thu, 25 Oct 2018 20:20:37 -0300 Subject: [PATCH 2/4] Makes sentence more explicit --- Doc/library/datetime.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 48fcc3de65c18a..9618db42a2f30d 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2013,8 +2013,9 @@ although not all objects support a :meth:`timetuple` method. Conversely, the :meth:`datetime.strptime` class method creates a :class:`.datetime` object from a string representing a date and time and a corresponding format string. ``datetime.strptime(date_string, format)`` is -similar to ``datetime(*(time.strptime(date_string, format)[0:6]))``, however, -``datetime.strptime()`` also retains both microseconds and timezone data. +equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``, except +when the format includes sub-second components or timezone offset information, +which are supported in ``datetime.strptime`` but not ``time.strptime``. For :class:`.time` objects, the format codes for year, month, and day should not be used, as time objects have no such values. If they're used anyway, ``1900`` From f145c66f83332edb6f4bf0c322dc09282615b4bf Mon Sep 17 00:00:00 2001 From: Gus Goulart Date: Sun, 28 Oct 2018 19:35:51 -0300 Subject: [PATCH 3/4] Mention silently ignored input --- Doc/library/datetime.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 9618db42a2f30d..690d60e06b35ac 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2015,7 +2015,8 @@ Conversely, the :meth:`datetime.strptime` class method creates a corresponding format string. ``datetime.strptime(date_string, format)`` is equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``, except when the format includes sub-second components or timezone offset information, -which are supported in ``datetime.strptime`` but not ``time.strptime``. +which are supported in ``datetime.strptime`` but are discarded by ``time.strptime``, +since ``time.strptime`` won't fail; however, it will silently ignore such input. For :class:`.time` objects, the format codes for year, month, and day should not be used, as time objects have no such values. If they're used anyway, ``1900`` From 3d8c8bba3e7753988507603d9d8ac990ef89b22d Mon Sep 17 00:00:00 2001 From: Gus Goulart Date: Mon, 29 Oct 2018 08:41:26 -0300 Subject: [PATCH 4/4] Remove unnecessary sentence --- Doc/library/datetime.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 690d60e06b35ac..46dd52e095a54e 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2015,8 +2015,7 @@ Conversely, the :meth:`datetime.strptime` class method creates a corresponding format string. ``datetime.strptime(date_string, format)`` is equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``, except when the format includes sub-second components or timezone offset information, -which are supported in ``datetime.strptime`` but are discarded by ``time.strptime``, -since ``time.strptime`` won't fail; however, it will silently ignore such input. +which are supported in ``datetime.strptime`` but are discarded by ``time.strptime``. For :class:`.time` objects, the format codes for year, month, and day should not be used, as time objects have no such values. If they're used anyway, ``1900``