MCPcopy Index your code
hub / github.com/python/cpython / Internaldate2tuple

Function Internaldate2tuple

Lib/imaplib.py:1762–1793  ·  view source on GitHub ↗

Parse an IMAP4 INTERNALDATE string. Return corresponding local time. The return value is a time.struct_time tuple or None if the string has wrong format.

(resp)

Source from the content-addressed store, hash-verified

1760Mon2num = {s.encode():n+1 for n, s in enumerate(Months[1:])}
1761
1762def Internaldate2tuple(resp):
1763 """Parse an IMAP4 INTERNALDATE string.
1764
1765 Return corresponding local time. The return value is a
1766 time.struct_time tuple or None if the string has wrong format.
1767 """
1768
1769 mo = InternalDate.match(resp)
1770 if not mo:
1771 return None
1772
1773 mon = Mon2num[mo.group('mon')]
1774 zonen = mo.group('zonen')
1775
1776 day = int(mo.group('day'))
1777 year = int(mo.group('year'))
1778 hour = int(mo.group('hour'))
1779 min = int(mo.group('min'))
1780 sec = int(mo.group('sec'))
1781 zoneh = int(mo.group('zoneh'))
1782 zonem = int(mo.group('zonem'))
1783
1784 # INTERNALDATE timezone must be subtracted to get UT
1785
1786 zone = (zoneh*60 + zonem)*60
1787 if zonen == b'-':
1788 zone = -zone
1789
1790 tt = (year, mon, day, hour, min, sec, -1, -1, -1)
1791 utc = calendar.timegm(tt) - zone
1792
1793 return time.localtime(utc)
1794
1795
1796

Callers

nothing calls this directly

Calls 2

matchMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…