Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Now handles 24h and 12h times

  • Loading branch information...
commit cfdba9bb96cda54cc8972fcf5e905e77d7ebc5a0 1 parent 21a25a4
@carmi authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 fb_parser.py
View
11 fb_parser.py
@@ -91,6 +91,14 @@ def get_json(self):
# FIXME: strip single quotes - causing json greif.
return json.dumps(self.js_output).encode('utf-8').replace("'","")
+ def parse_time(self, time_str):
+ # Handle both 24h and 12h time strings.
+ try:
+ #June 15, 2011 at 10:31 am
+ return datetime.strptime(time_str, "%B %d, %Y at %I:%M %p")
+ except ValueError:
+ return datetime.strptime(time_str, "%B %d, %Y at %H:%M")
+
def write_data(self):
f = open(self.js_data_file, 'w')
# Contstruct a javascript file that can be easily linked to.
@@ -148,7 +156,8 @@ def parse_wall(self, html):
self.profile_counter.update([profile])
time_text = entry.findChild(name='span', attrs={'class' : 'time'}).extract().text
- time_object = datetime.strptime(time_text, "%B %d, %Y at %I:%M %p")
+
+ time_object = self.parse_time(time_text)
privacy_img = entry.findChild(name='img', attrs={'class' : 'privacy'})
if privacy_img:
Please sign in to comment.
Something went wrong with that request. Please try again.