From e99416c87450464eb4445be8368743cf61ff6270 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Thu, 3 Jan 2013 19:38:29 +0100 Subject: [PATCH] fix parsing of dates --- modules/cmso/pages.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/cmso/pages.py b/modules/cmso/pages.py index 26805743..c4cfa66e 100644 --- a/modules/cmso/pages.py +++ b/modules/cmso/pages.py @@ -87,12 +87,12 @@ class TransactionsPage(BasePage): t = Transaction(0) raw = div.xpath('.//div[@class="row-lib"]')[0].text date = div.xpath('.//span')[0].text.strip() - m = re.match('(\d+) ([^ ]+)( \d+)?$', date) + m = re.match('(\d+)(er)? ([^ ]+)( \d+)?$', date) if m: dd = int(m.group(1)) - mm = self.months.index(m.group(2)) + 1 - if m.group(3) is not None: - yy = int(m.group(3)) + mm = self.months.index(m.group(3)) + 1 + if m.group(4) is not None: + yy = int(m.group(4)) else: d = datetime.date.today() @@ -102,8 +102,6 @@ class TransactionsPage(BasePage): d = d.replace(year=d.year-1, month=mm, day=dd) yy = d.year - if d > datetime.date.today(): - yy -= 1 date = datetime.date(yy, mm, dd)