diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-07-20 15:41:21 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-07-20 15:41:21 (GMT) |
commit | 875048bd4c95ae90c3e541cad681b11436ce1f3f (patch) | |
tree | ebd084a91ec6a66f3747cfd16b013da25b9654c1 /Doc/library/email.util.rst | |
parent | 3e44612726ff8be8b7b43aa9043441206a35a08f (diff) | |
download | cpython-875048bd4c95ae90c3e541cad681b11436ce1f3f.zip cpython-875048bd4c95ae90c3e541cad681b11436ce1f3f.tar.gz cpython-875048bd4c95ae90c3e541cad681b11436ce1f3f.tar.bz2 |
#665194: support roundtripping RFC2822 date stamps in the email.utils module
Diffstat (limited to 'Doc/library/email.util.rst')
-rw-r--r-- | Doc/library/email.util.rst | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Doc/library/email.util.rst b/Doc/library/email.util.rst index 4d96857..2f9ef89 100644 --- a/Doc/library/email.util.rst +++ b/Doc/library/email.util.rst @@ -81,6 +81,20 @@ There are several useful utilities provided in the :mod:`email.utils` module: indexes 6, 7, and 8 of the result tuple are not usable. +.. function:: parsedate_to_datetime(date) + + The inverse of :func:`format_datetime`. Performs the same function as + :func:`parsedate`, but on success returns a :mod:`~datetime.datetime`. If + the input date has a timezone of ``-0000``, the ``datetime`` will be a naive + ``datetime``, and if the date is conforming to the RFCs it will represent a + time in UTC but with no indication of the actual source timezone of the + message the date comes from. If the input date has any other valid timezone + offset, the ``datetime`` will be an aware ``datetime`` with the + corresponding a :class:`~datetime.timezone` :class:`~datetime.tzinfo`. + + .. versionadded:: 3.3 + + .. function:: mktime_tz(tuple) Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC timestamp. It @@ -112,6 +126,20 @@ There are several useful utilities provided in the :mod:`email.utils` module: ``False``. The default is ``False``. +.. function:: format_datetime(dt, usegmt=False) + + Like ``formatdate``, but the input is a :mod:`datetime` instance. If it is + a naive datetime, it is assumed to be "UTC with no information about the + source timezone", and the conventional ``-0000`` is used for the timezone. + If it is an aware ``datetime``, then the numeric timezone offset is used. + If it is an aware timezone with offset zero, then *usegmt* may be set to + ``True``, in which case the string ``GMT`` is used instead of the numeric + timezone offset. This provides a way to generate standards conformant HTTP + date headers. + + .. versionadded:: 3.3 + + .. function:: make_msgid(idstring=None, domain=None) Returns a string suitable for an :rfc:`2822`\ -compliant |