Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Side by Side Diff: Doc/library/email.util.rst

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/doctest.rst ('k') | Doc/library/faulthandler.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`email`: Miscellaneous utilities 1 :mod:`email`: Miscellaneous utilities
2 ------------------------------------- 2 -------------------------------------
3 3
4 .. module:: email.utils 4 .. module:: email.utils
5 :synopsis: Miscellaneous email package utilities. 5 :synopsis: Miscellaneous email package utilities.
6 6
7 7
8 There are several useful utilities provided in the :mod:`email.utils` module: 8 There are several useful utilities provided in the :mod:`email.utils` module:
9 9
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 73
74 .. function:: parsedate_tz(date) 74 .. function:: parsedate_tz(date)
75 75
76 Performs the same function as :func:`parsedate`, but returns either ``None`` or 76 Performs the same function as :func:`parsedate`, but returns either ``None`` or
77 a 10-tuple; the first 9 elements make up a tuple that can be passed directly to 77 a 10-tuple; the first 9 elements make up a tuple that can be passed directly to
78 :func:`time.mktime`, and the tenth is the offset of the date's timezone from UTC 78 :func:`time.mktime`, and the tenth is the offset of the date's timezone from UTC
79 (which is the official term for Greenwich Mean Time) [#]_. If the input stri ng 79 (which is the official term for Greenwich Mean Time) [#]_. If the input stri ng
80 has no timezone, the last element of the tuple returned is ``None``. Note th at 80 has no timezone, the last element of the tuple returned is ``None``. Note th at
81 indexes 6, 7, and 8 of the result tuple are not usable. 81 indexes 6, 7, and 8 of the result tuple are not usable.
82
83
84 .. function:: parsedate_to_datetime(date)
85
86 The inverse of :func:`format_datetime`. Performs the same function as
87 :func:`parsedate`, but on success returns a :mod:`~datetime.datetime`. If
88 the input date has a timezone of ``-0000``, the ``datetime`` will be a naive
89 ``datetime``, and if the date is conforming to the RFCs it will represent a
90 time in UTC but with no indication of the actual source timezone of the
91 message the date comes from. If the input date has any other valid timezone
92 offset, the ``datetime`` will be an aware ``datetime`` with the
93 corresponding a :class:`~datetime.timezone` :class:`~datetime.tzinfo`.
94
95 .. versionadded:: 3.3
96 82
97 83
98 .. function:: mktime_tz(tuple) 84 .. function:: mktime_tz(tuple)
99 85
100 Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC timestamp. It 86 Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC timestamp. It
101 the timezone item in the tuple is ``None``, assume local time. Minor 87 the timezone item in the tuple is ``None``, assume local time. Minor
102 deficiency: :func:`mktime_tz` interprets the first 8 elements of *tuple* as a 88 deficiency: :func:`mktime_tz` interprets the first 8 elements of *tuple* as a
103 local time and then compensates for the timezone difference. This may yield a 89 local time and then compensates for the timezone difference. This may yield a
104 slight error around changes in daylight savings time, though not worth worryi ng 90 slight error around changes in daylight savings time, though not worth worryi ng
105 about for common use. 91 about for common use.
(...skipping 11 matching lines...) Expand all
117 103
118 Optional *localtime* is a flag that when ``True``, interprets *timeval*, and 104 Optional *localtime* is a flag that when ``True``, interprets *timeval*, and
119 returns a date relative to the local timezone instead of UTC, properly taking 105 returns a date relative to the local timezone instead of UTC, properly taking
120 daylight savings time into account. The default is ``False`` meaning UTC is 106 daylight savings time into account. The default is ``False`` meaning UTC is
121 used. 107 used.
122 108
123 Optional *usegmt* is a flag that when ``True``, outputs a date string with t he 109 Optional *usegmt* is a flag that when ``True``, outputs a date string with t he
124 timezone as an ascii string ``GMT``, rather than a numeric ``-0000``. This is 110 timezone as an ascii string ``GMT``, rather than a numeric ``-0000``. This is
125 needed for some protocols (such as HTTP). This only applies when *localtime* is 111 needed for some protocols (such as HTTP). This only applies when *localtime* is
126 ``False``. The default is ``False``. 112 ``False``. The default is ``False``.
127
128
129 .. function:: format_datetime(dt, usegmt=False)
130
131 Like ``formatdate``, but the input is a :mod:`datetime` instance. If it is
132 a naive datetime, it is assumed to be "UTC with no information about the
133 source timezone", and the conventional ``-0000`` is used for the timezone.
134 If it is an aware ``datetime``, then the numeric timezone offset is used.
135 If it is an aware timezone with offset zero, then *usegmt* may be set to
136 ``True``, in which case the string ``GMT`` is used instead of the numeric
137 timezone offset. This provides a way to generate standards conformant HTTP
138 date headers.
139
140 .. versionadded:: 3.3
141 113
142 114
143 .. function:: make_msgid(idstring=None, domain=None) 115 .. function:: make_msgid(idstring=None, domain=None)
144 116
145 Returns a string suitable for an :rfc:`2822`\ -compliant 117 Returns a string suitable for an :rfc:`2822`\ -compliant
146 :mailheader:`Message-ID` header. Optional *idstring* if given, is a string 118 :mailheader:`Message-ID` header. Optional *idstring* if given, is a string
147 used to strengthen the uniqueness of the message id. Optional *domain* if 119 used to strengthen the uniqueness of the message id. Optional *domain* if
148 given provides the portion of the msgid after the '@'. The default is the 120 given provides the portion of the msgid after the '@'. The default is the
149 local hostname. It is not normally necessary to override this default, but 121 local hostname. It is not normally necessary to override this default, but
150 may be useful certain cases, such as a constructing distributed system that 122 may be useful certain cases, such as a constructing distributed system that
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 Decode parameters list according to :rfc:`2231`. *params* is a sequence of 157 Decode parameters list according to :rfc:`2231`. *params* is a sequence of
186 2-tuples containing elements of the form ``(content-type, string-value)``. 158 2-tuples containing elements of the form ``(content-type, string-value)``.
187 159
188 160
189 .. rubric:: Footnotes 161 .. rubric:: Footnotes
190 162
191 .. [#] Note that the sign of the timezone offset is the opposite of the sign of the 163 .. [#] Note that the sign of the timezone offset is the opposite of the sign of the
192 ``time.timezone`` variable for the same timezone; the latter variable follows 164 ``time.timezone`` variable for the same timezone; the latter variable follows
193 the POSIX standard while this module follows :rfc:`2822`. 165 the POSIX standard while this module follows :rfc:`2822`.
194 166
OLDNEW
« no previous file with comments | « Doc/library/doctest.rst ('k') | Doc/library/faulthandler.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+