From 5ffc41e3fa6000c2b9033a22ac0635bd6d3ae325 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Tue, 21 May 2013 21:43:02 +0300 Subject: Detect alternate date format --- gsxws/core.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gsxws/core.py') diff --git a/gsxws/core.py b/gsxws/core.py index 1b7da60..73c2b29 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -399,6 +399,11 @@ class GsxObject(object): m, d, y = v.split('/') v = date(2000+int(y), int(m), int(d)).isoformat() + # seems that some dates are in the format "yyyy-mm-dd" + if re.search(r'^\d{4}-\d{2}-\d{2}$', v): + y, m, d = v.split('-') + v = date(int(y), int(m), int(d)).isoformat() + # strip currency prefix and munge into float if re.search(r'Price$', k): v = float(re.sub(r'[A-Z ,]', '', v)) @@ -408,7 +413,7 @@ class GsxObject(object): if re.search(r'TimeStamp$', k): v = datetime.strptime(v, '%d-%b-%y %H:%M:%S') - # convert Y and N to corresponding boolean + # convert Y and N to boolean if re.search(r'^[YN]$', k): v = (v == 'Y') -- cgit v1.2.3