Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

Commit

Permalink
* Fix date parsing issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Allen committed May 19, 2014
1 parent bf2c765 commit f729617
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions enzymeproject/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@
from datetime import timedelta, datetime


def parse_date(datestring):
return (
datetime.strptime(datestring[:-6].replace("T", " "), "%Y-%m-%d %H:%M:%S") +
timedelta(hours=int(datestring[-6:-3]))
)
def parse_date(date_string):
try:
# get pure date string without timezone information
pure_date = date_string.replace("T", " ").replace("Z", " ").strip()[0:19]

return (
datetime.strptime(
pure_date,
"%Y-%m-%d %H:%M:%S"
) +
timedelta(
hours=int(pure_date[-8:-6])
)
)

except ValueError:
return None


def get_commits_feed(feed_url, limit=None):
Expand Down

0 comments on commit f729617

Please sign in to comment.