Created
June 23, 2020 08:15
-
-
Save fffonion/88568d35777866a860b61e7961d1dc45 to your computer and use it in GitHub Desktop.
rfc822
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import time | |
def rfc822(s): | |
_ = re.findall("[A-z][a-z]+,\s*([^\+G]+)(?:$|\s([\+\-]*)(\d+|GMT))", s) | |
if not s: | |
print("%s is not RFC822 Date" % s) | |
return 0 | |
dt, sgn, tz = _[0] | |
if tz == "GMT": | |
tz = 0 | |
return time.mktime(time.strptime(dt, "%d %b %Y %H:%M:%S")) - (-1 if sgn == '-' else 1) * int(tz) * 36 # 0800 => 800 / 100 * 3600 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment