Skip to content

Instantly share code, notes, and snippets.

@infinity0
Created June 22, 2015 19:53
Show Gist options
  • Save infinity0/e9d6fe71c1827ce0f088 to your computer and use it in GitHub Desktop.
Save infinity0/e9d6fe71c1827ce0f088 to your computer and use it in GitHub Desktop.
RFC2822 to ISO8601 date converter
#!/usr/bin/python
# RFC2822 to ISO8601 date converter, that doesn't require you to fuck with the TZ variable.
# Fuck the POSIX time functions.
import time, email.utils, sys
t = email.utils.parsedate_tz(sys.argv[1])
t, tz = t[:-1], t[-1]
print(time.strftime("%Y-%m-%dT%H:%M:%S", t) + "{0:+03d}{1:02d}".format(tz/3600, tz/60%60))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment