]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 88114 via svnmerge from
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>
Wed, 19 Jan 2011 21:48:20 +0000 (21:48 +0000)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>
Wed, 19 Jan 2011 21:48:20 +0000 (21:48 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r88114 | alexander.belopolsky | 2011-01-19 14:53:30 -0500 (Wed, 19 Jan 2011) | 5 lines

  Issue #10934: Fixed and expanded Internaldate2tuple() and
  Time2Internaldate() documentation.  Thanks Joe Peterson for the report
  and the original patch.
........

Doc/library/imaplib.rst
Lib/imaplib.py

index e18d7d54248763026f1f2da85b7e516181c528b1..72ea7e8533c831856a75370a0287f12720c49cdb 100644 (file)
@@ -84,9 +84,9 @@ The following utility functions are defined:
 
 .. function:: Internaldate2tuple(datestr)
 
-   Converts an IMAP4 INTERNALDATE string to Coordinated Universal Time. Returns a
-   :mod:`time` module tuple.
-
+   Parse an IMAP4 ``INTERNALDATE`` string and return corresponding local
+   time.  The return value is a :class:`time.struct_time` instance or
+   None if the string has wrong format.
 
 .. function:: Int2AP(num)
 
@@ -101,9 +101,13 @@ The following utility functions are defined:
 
 .. function:: Time2Internaldate(date_time)
 
-   Converts a :mod:`time` module tuple to an IMAP4 ``INTERNALDATE`` representation.
-   Returns a string in the form: ``"DD-Mmm-YYYY HH:MM:SS +HHMM"`` (including
-   double-quotes).
+   Convert *date_time* to an IMAP4 ``INTERNALDATE`` representation.  The
+   return value is a string in the form: ``"DD-Mmm-YYYY HH:MM:SS
+   +HHMM"`` (including double-quotes).  The *date_time* argument can be a
+   number (int or float) represening seconds since epoch (as returned
+   by :func:`time.time`), a 9-tuple representing local time (as returned by
+   :func:`time.localtime`), or a double-quoted string.  In the last case, it
+   is assumed to already be in the correct format.
 
 Note that IMAP4 message numbers change as the mailbox changes; in particular,
 after an ``EXPUNGE`` command performs deletions the remaining messages are
index f66a83bae2a87a09489a1e6a6d0fff5d39b1bef4..fdae445ae1516e52d11145118dd812eeed50176c 100644 (file)
@@ -1321,9 +1321,10 @@ Mon2num = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,
         'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}
 
 def Internaldate2tuple(resp):
-    """Convert IMAP4 INTERNALDATE to UT.
+    """Parse an IMAP4 INTERNALDATE string.
 
-    Returns Python time module tuple.
+    Return corresponding local time.  The return value is a
+    time.struct_time instance or None if the string has wrong format.
     """
 
     mo = InternalDate.match(resp)
@@ -1390,9 +1391,14 @@ def ParseFlags(resp):
 
 def Time2Internaldate(date_time):
 
-    """Convert 'date_time' to IMAP4 INTERNALDATE representation.
+    """Convert date_time to IMAP4 INTERNALDATE representation.
 
-    Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'
+    Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'.  The
+    date_time argument can be a number (int or float) represening
+    seconds since epoch (as returned by time.time()), a 9-tuple
+    representing local time (as returned by time.localtime()), or a
+    double-quoted string.  In the last case, it is assumed to already
+    be in the correct format.
     """
 
     if isinstance(date_time, (int, float)):