Overview
Comment: | [fr][core] vérification des dates |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | fr | core | rg |
Files: | files | file ages | folders |
SHA3-256: |
2485a4e3fa053c96917e26ac18199a65 |
User & Date: | olr on 2018-07-16 15:20:08 |
Other Links: | branch diff | manifest | tags |
Context
2018-07-17
| ||
06:24 | [fr] faux positif: quelle va être… check-in: 5d1225ab9b user: olr tags: fr, rg | |
2018-07-16
| ||
15:20 | [fr][core] vérification des dates check-in: 2485a4e3fa user: olr tags: fr, core, rg | |
15:19 | [fr] faux positifs avec <nous sommes> check-in: 91754eb5e3 user: olr tags: fr, rg | |
Changes
Modified gc_lang/fr/modules/gce_date_verif.py from [1265100649] to [ea534786c6].
1 2 3 4 5 6 7 8 9 10 | #### GRAMMAR CHECKING ENGINE PLUGIN #### Check date validity _lDay = ["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"] _dMonth = { "janvier":1, "février":2, "mars":3, "avril":4, "mai":5, "juin":6, "juillet":7, "août":8, "aout":8, "septembre":9, "octobre":10, "novembre":11, "décembre":12 } import datetime | | | | | | | | | > > | | > | | | | | | > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #### GRAMMAR CHECKING ENGINE PLUGIN #### Check date validity _lDay = ["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"] _dMonth = { "janvier":1, "février":2, "mars":3, "avril":4, "mai":5, "juin":6, "juillet":7, "août":8, "aout":8, "septembre":9, "octobre":10, "novembre":11, "décembre":12 } import datetime def checkDate (sDay, sMonth, sYear): "to use if <sMonth> is a number" try: return datetime.date(int(sYear), int(sMonth), int(sDay)) except ValueError: return False except: return True def checkDateWithString (sDay, sMonth, sYear): "to use if <sMonth> is a noun" try: return datetime.date(int(sYear), _dMonth.get(sMonth.lower(), ""), int(sDay)) except ValueError: return False except: return True def checkDay (sWeekday, sDate): "to use if <sMonth> is a number" print(sWeekday, sDay) sDay, sMonth, sYear = sDate.split("-") oDate = checkDate(sDay, sMonth, sYear) if oDate and _lDay[oDate.weekday()] != sWeekday.lower(): return False return True def checkDayWithString (sWeekday, sDay, sMonth, sYear): "to use if <sMonth> is a noun" oDate = checkDate(sDay, _dMonth.get(sMonth, ""), sYear) if oDate and _lDay[oDate.weekday()] != sWeekday.lower(): return False return True def getDay (sDate): "to use if <sMonth> is a number" sDay, sMonth, sYear = sDate.split("-") return _lDay[datetime.date(int(sYear), int(sMonth), int(sDay)).weekday()] def getDayWithString (sDay, sMonth, sYear): "to use if <sMonth> is a noun" return _lDay[datetime.date(int(sYear), _dMonth.get(sMonth.lower(), ""), int(sDay)).weekday()] |