fix parsing date

This commit is contained in:
Romain Bignon 2013-02-22 16:38:34 +01:00
commit 634d7a7c56

View file

@ -19,7 +19,7 @@
from decimal import Decimal from decimal import Decimal
from datetime import date from datetime import date, timedelta
import re import re
import hashlib import hashlib
@ -43,7 +43,7 @@ class AccountsList(BasePage):
def on_loaded(self): def on_loaded(self):
pass pass
monthvalue = {u'janv.': '01', u'févr.': '02', u'mars.': '03', u'avr.': '04', monthvalue = {u'janv.': '01', u'févr.': '02', u'mars': '03', u'avr.': '04',
u'mai': '05', u'juin': '06', u'juil.': '07', u'août': '08', u'mai': '05', u'juin': '06', u'juil.': '07', u'août': '08',
u'sept.': '09', u'oct.': '10', u'nov.': '11', u'déc.': '12', u'sept.': '09', u'oct.': '10', u'nov.': '11', u'déc.': '12',
} }
@ -78,6 +78,11 @@ class AccountsList(BasePage):
textdate = table.find('.//td[@class="elmt tdate"]').text_content() textdate = table.find('.//td[@class="elmt tdate"]').text_content()
except AttributeError: except AttributeError:
continue continue
if textdate == 'hier':
textdate = (date.today() - timedelta(days=1)).strftime('%d/%m/%Y')
elif textdate == "aujourd'hui":
textdate = date.today().strftime('%d/%m/%Y')
else:
frenchmonth = textdate.split(' ')[1] frenchmonth = textdate.split(' ')[1]
month = self.monthvalue[frenchmonth] month = self.monthvalue[frenchmonth]
textdate = textdate.replace(' ', '') textdate = textdate.replace(' ', '')