From 03ad0a2ee75db5d1ee6a1b42943ef39bb3e1f9d5 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Sun, 5 Jul 2009 19:34:46 -0500 Subject: [PATCH] Added datetime parsing. --- parsers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/parsers.py b/parsers.py index 8330b84..b8866fc 100644 --- a/parsers.py +++ b/parsers.py @@ -1,3 +1,5 @@ +from datetime import datetime + try: import json except ImportError: @@ -7,6 +9,10 @@ def parse_error(data): return json.loads(data)['error'] +def _parse_datetime(str): + + return datetime.strptime(str, '%a %b %d %H:%M:%S +0000 %Y') + def _parse_user(obj, classes): user = classes['user']() @@ -27,6 +33,8 @@ def _parse_status(obj, classes): for k,v in obj.items(): if k == 'user': setattr(status, k, _parse_user(v, classes)) + elif k == 'created_at': + setattr(status, k, _parse_datetime(v)) else: setattr(status, k, v) return status -- 2.25.1