[Mpuls-commits] r518 - in wasko/trunk: . waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed May 27 10:36:34 CEST 2009
Author: teichmann
Date: 2009-05-27 10:36:33 +0200 (Wed, 27 May 2009)
New Revision: 518
Modified:
wasko/trunk/ChangeLog.txt
wasko/trunk/waskaweb/model/semantic.py
Log:
Fixed issue247
Modified: wasko/trunk/ChangeLog.txt
===================================================================
--- wasko/trunk/ChangeLog.txt 2009-05-26 14:06:46 UTC (rev 517)
+++ wasko/trunk/ChangeLog.txt 2009-05-27 08:36:33 UTC (rev 518)
@@ -1,3 +1,11 @@
+2009-05-27 Sascha L. Teichmann <sascha.teichmann at intevation.de>
+
+ Fixed issue247
+
+ * waskaweb/model/semantic.py: Dates 'dd.mm' are now completed
+ to 'dd.mm.yyyy' with yyyy being the current. For invalid dates
+ a format suggestion is made.
+
2009-05-26 Sascha L. Teichmann <sascha.teichmann at intevation.de>
Fixed issue205, issue219
Modified: wasko/trunk/waskaweb/model/semantic.py
===================================================================
--- wasko/trunk/waskaweb/model/semantic.py 2009-05-26 14:06:46 UTC (rev 517)
+++ wasko/trunk/waskaweb/model/semantic.py 2009-05-27 08:36:33 UTC (rev 518)
@@ -171,6 +171,8 @@
DATE_ISO_IDX = (3, 2, 1)
YEAR = re.compile(r"([0-9]{1,4})")
+ DAY_MONTH = re.compile(r"([0-9]{1,2})\.([0-9]{1,2})")
+
def convert(self, value, nc):
return self.checkAndConvert(value, nc)
@@ -180,6 +182,16 @@
if value[:2].lower() == u"un":
return UNKNOWN_DATE
+ m = DateChecker.DAY_MONTH.match(value)
+ if m:
+ day = int(m.group(1))
+ month = int(m.group(2))
+ year = date.today().year
+ try:
+ return date(year, month, day)
+ except ValueError:
+ raise SematicError(u"'%s' ist kein gültiges Datum. (Format: DD.MM.JJJJ)" % value)
+
for reg, idx in ((DateChecker.DATE, DateChecker.DATE_IDX), (DateChecker.DATE_ISO, DateChecker.DATE_ISO_IDX)):
m = reg.match(value)
if not m: continue
@@ -194,7 +206,7 @@
try:
return date(year, month, day)
except ValueError:
- raise SematicError(u"'%s' ist kein gültiges Datum." % value)
+ raise SematicError(u"'%s' ist kein gültiges Datum. (Format: DD.MM.JJJJ)" % value)
m = DateChecker.YEAR.match(value)
if m:
@@ -207,9 +219,9 @@
try:
return date(year, 1, 1)
except ValueError:
- raise SematicError(u"'%s' ist kein gültiges Datum." % value)
+ raise SematicError(u"'%s' ist kein gültiges Datum. (Format: DD.MM.JJJJ)" % value)
- raise SematicError("'%s' ist kein Datum." % value)
+ raise SematicError("'%s' ist kein Datum. (Format: DD.MM.JJJJ)" % value)
class ChoiceChecker(ValueChecker):
More information about the Mpuls-commits
mailing list