Skip to content

Commit

Permalink
Fixed datetime parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignas committed Sep 22, 2011
1 parent 2eca9ae commit 7ddbbb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@

setup(
name='busyflow.pivotal',
version='0.1.5',
version='0.1.6',
description='Pivotal API client library.',
author='Ignas Mikalajunas',
author_email='ignas@nous.lt',
Expand Down
13 changes: 10 additions & 3 deletions src/busyflow/pivotal/__init__.py
Expand Up @@ -40,13 +40,20 @@ def parse_csv(node):
return value.split(",")


def parse_string_to_dt(value):
try:
time_tuple = time.strptime(value, '%Y/%m/%d %H:%M:%S %Z')
except ValueError:
time_tuple = time.strptime(' '.join(value.split(' ')[:-1]), '%Y/%m/%d %H:%M:%S')
t = list(time_tuple)[:-2]
return datetime.datetime(*t)


def parse_datetime(node):
if len(node.childNodes) == 0:
return None
value = node.childNodes[0].wholeText.strip()
t = list(time.strptime(value, '%Y/%m/%d %H:%M:%S %Z'))[:-2]
return datetime.datetime(*t)

return parse_string_to_dt(value)

def parse_list(parent_node):
new_list = []
Expand Down

0 comments on commit 7ddbbb2

Please sign in to comment.