Last active
August 29, 2015 13:56
-
-
Save aoshiman/9018479 to your computer and use it in GitHub Desktop.
convert datetime format rfc2822 to iso8601
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
# -*- coding: utf-8 -*- | |
import sys | |
from email.utils import parsedate_tz, mktime_tz | |
from datetime import datetime | |
def conv_2822_to_8601(s): | |
time_tuple = parsedate_tz(s) | |
time_stamp = mktime_tz(time_tuple) | |
return datetime.fromtimestamp(time_stamp) | |
if __name__ == '__main__': | |
print(conv_2822_to_8601(sys.argv[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment