diff options
author | Filipp Lepalaan <f@230.to> | 2013-05-21 21:43:02 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-05-21 21:43:02 +0300 |
commit | 5ffc41e3fa6000c2b9033a22ac0635bd6d3ae325 (patch) | |
tree | 120ecbc18ddaa8ce218caa45cd49c49c134c1f05 | |
parent | 65b27c4083e2ef6cdd2a88b89cd25e587bdcec04 (diff) | |
download | py-gsxws-5ffc41e3fa6000c2b9033a22ac0635bd6d3ae325.tar.gz py-gsxws-5ffc41e3fa6000c2b9033a22ac0635bd6d3ae325.tar.bz2 py-gsxws-5ffc41e3fa6000c2b9033a22ac0635bd6d3ae325.zip |
Detect alternate date format
-rw-r--r-- | gsxws/core.py | 7 |
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') |