aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws/core.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-05-21 21:43:02 +0300
committerFilipp Lepalaan <f@230.to>2013-05-21 21:43:02 +0300
commit5ffc41e3fa6000c2b9033a22ac0635bd6d3ae325 (patch)
tree120ecbc18ddaa8ce218caa45cd49c49c134c1f05 /gsxws/core.py
parent65b27c4083e2ef6cdd2a88b89cd25e587bdcec04 (diff)
downloadpy-gsxws-5ffc41e3fa6000c2b9033a22ac0635bd6d3ae325.tar.gz
py-gsxws-5ffc41e3fa6000c2b9033a22ac0635bd6d3ae325.tar.bz2
py-gsxws-5ffc41e3fa6000c2b9033a22ac0635bd6d3ae325.zip
Detect alternate date format
Diffstat (limited to 'gsxws/core.py')
-rw-r--r--gsxws/core.py7
1 files changed, 6 insertions, 1 deletions
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')