rest25/library/email.util.rst => rest262/library/email.util.rst
n1+:mod:`email`: Miscellaneous utilities
2+-------------------------------------
3+ 
1.. module:: email.utils
2   :synopsis: Miscellaneous email package utilities.
3
4
5There are several useful utilities provided in the :mod:`email.utils` module:
6
7
8.. function:: quote(str)
52
53.. function:: parsedate(date)
54
55   Attempts to parse a date according to the rules in :rfc:`2822`. however, some
56   mailers don't follow that format as specified, so :func:`parsedate` tries to
57   guess correctly in such cases.  *date* is a string containing an :rfc:`2822`
58   date, such as  ``"Mon, 20 Nov 1995 19:12:08 -0500"``.  If it succeeds in parsing
59   the date, :func:`parsedate` returns a 9-tuple that can be passed directly to
n60-   :func:`time.mktime`; otherwise ``None`` will be returned.  Note that fields 6,
n63+   :func:`time.mktime`; otherwise ``None`` will be returned.  Note that indexes 6,
61   7, and 8 of the result tuple are not usable.
62
63
64.. function:: parsedate_tz(date)
65
66   Performs the same function as :func:`parsedate`, but returns either ``None`` or
67   a 10-tuple; the first 9 elements make up a tuple that can be passed directly to
68   :func:`time.mktime`, and the tenth is the offset of the date's timezone from UTC
69   (which is the official term for Greenwich Mean Time) [#]_.  If the input string
70   has no timezone, the last element of the tuple returned is ``None``.  Note that
t71-   fields 6, 7, and 8 of the result tuple are not usable.
t74+   indexes 6, 7, and 8 of the result tuple are not usable.
72
73
74.. function:: mktime_tz(tuple)
75
76   Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC timestamp.  It
77   the timezone item in the tuple is ``None``, assume local time.  Minor
78   deficiency: :func:`mktime_tz` interprets the first 8 elements of *tuple* as a
79   local time and then compensates for the timezone difference.  This may yield a
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op