From: David Wolever Date: Mon, 12 Aug 2013 19:50:10 +0000 (-0400) Subject: Issue #17701: Improving strftime documentation X-Git-Tag: v2.7.6rc1~248 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=452dd381500d5486ca782447a89f54fc19c0e384;p=thirdparty%2FPython%2Fcpython.git Issue #17701: Improving strftime documentation --- 452dd381500d5486ca782447a89f54fc19c0e384 diff --cc Doc/library/datetime.rst index 7219cea64574,e33f3f06ba19..be41e1210db7 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@@ -1737,12 -1736,35 +1736,35 @@@ Notes produce them in :func:`strftime` output. (4) - When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used in - calculations when the day of the week and the year are specified. + ``%f`` is an extension to the set of format characters in the C standard + (but implemented separately in datetime objects, and therefore always + available). When used with the :meth:`strptime` method, the ``%f`` - directive accepts from one to six digits and zero pads on the right. ++ directive accepts from one to six digits and zero pads on the right. + + .. versionadded:: 2.6 (5) - For example, if :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, - ``%z`` is replaced with the string ``'-0330'``. + For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty + strings. + + For an aware object: + + ``%z`` + :meth:`utcoffset` is transformed into a 5-character string of the form + +HHMM or -HHMM, where HH is a 2-digit string giving the number of UTC + offset hours, and MM is a 2-digit string giving the number of UTC offset + minutes. For example, if :meth:`utcoffset` returns + ``timedelta(hours=-3, minutes=-30)``, ``%z`` is replaced with the string + ``'-0330'``. + + ``%Z`` + If :meth:`tzname` returns ``None``, ``%Z`` is replaced by an empty + string. Otherwise ``%Z`` is replaced by the returned value, which must + be a string. + + (6) + When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used + in calculations when the day of the week and the year are specified. .. rubric:: Footnotes diff --cc Misc/NEWS index c9b7fdc6d255,9c472ddbf9f9..5e4a1bee3c65 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -164,6 -39,6 +164,7 @@@ Test Documentation ------------- ++- Issue #17701: Improving strftime documentation. - Issue #17844: Refactor a documentation of Python specific encodings. Add links to encoders and decoders for binary-to-binary codecs.