Skip to content

Instantly share code, notes, and snippets.

@sbp
Created June 8, 2011 15:37
Show Gist options
  • Save sbp/1014662 to your computer and use it in GitHub Desktop.
Save sbp/1014662 to your computer and use it in GitHub Desktop.
Parse date in python ignoring timezone, python 2.4 compatible
#!/usr/bin/env python
import time, calendar, datetime
input = '2011-05-26T16:02:59.199400+00:00'
input = input.split('.', 1)[0]
input = input.split('+', 1)[0]
then = time.strptime(input, '%Y-%m-%dT%H:%M:%S')
then = datetime.datetime.utcfromtimestamp(calendar.timegm(then))
td = datetime.datetime.utcnow() - then
seconds = td.seconds + td.days * 24 * 3600
minutes = float(seconds) / 60
print minutes < 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment