summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2011-01-10 23:28:33 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2011-01-10 23:28:33 (GMT)
commit085556ae89cc1fba985855233e6d9e3b553466fb (patch)
tree461cd4ab62dbf6bb5d2837a498ba680837172eb0 /Doc/library
parent262cc7f6b667ac4723b0199654d26234788739c5 (diff)
downloadcpython-085556ae89cc1fba985855233e6d9e3b553466fb.zip
cpython-085556ae89cc1fba985855233e6d9e3b553466fb.tar.gz
cpython-085556ae89cc1fba985855233e6d9e3b553466fb.tar.bz2
Improved description of %Y directive.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/datetime.rst23
1 files changed, 16 insertions, 7 deletions
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 2ace965..4ed1e01 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -1661,10 +1661,6 @@ version) requires, and these work on all platforms with a standard C
implementation. Note that the 1999 version of the C standard added additional
format codes.
-The exact range of years for which :meth:`strftime` works also varies
-across platforms. Regardless of platform, years before 1000 cannot be
-used with ``datetime`` module ``strftime()`` methods.
-
+-----------+--------------------------------+-------+
| Directive | Meaning | Notes |
+===========+================================+=======+
@@ -1737,10 +1733,11 @@ used with ``datetime`` module ``strftime()`` methods.
| ``%y`` | Year without century as a | |
| | decimal number [00,99]. | |
+-----------+--------------------------------+-------+
-| ``%Y`` | Year with century as a decimal | |
-| | number. | |
+| ``%Y`` | Year with century as a decimal | \(5) |
+| | number [0001,9999] (strptime), | |
+| | [1000,9999] (strftime). | |
+-----------+--------------------------------+-------+
-| ``%z`` | UTC offset in the form +HHMM | \(5) |
+| ``%z`` | UTC offset in the form +HHMM | \(6) |
| | or -HHMM (empty string if the | |
| | the object is naive). | |
+-----------+--------------------------------+-------+
@@ -1772,6 +1769,18 @@ Notes:
calculations when the day of the week and the year are specified.
(5)
+ For technical reasons, :meth:`strftime` method does not support
+ dates with year < 1000: ``t.strftime(format)`` will raise a
+ :exc:`ValueError` even if ``format`` does not contain ``%Y``
+ directive. The :meth:`strptime` method can parse years in the full
+ [1, 9999] range, but years < 1000 must be zero-filled to 4-digit
+ width.
+
+ .. versionchanged:: 3.2
+ In previous versions, :meth:`strftime` method was restricted to
+ years >= 1900.
+
+(6)
For example, if :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``,
``%z`` is replaced with the string ``'-0330'``.