|
From: <sub...@co...> - 2007-10-21 00:22:19
|
Author: ianb
Date: 2007-10-20 18:22:19 -0600 (Sat, 20 Oct 2007)
New Revision: 3101
Modified:
FormEncode/trunk/docs/news.txt
FormEncode/trunk/formencode/validators.py
Log:
Fix for DateConverter.from_python
Modified: FormEncode/trunk/docs/news.txt
===================================================================
--- FormEncode/trunk/docs/news.txt 2007-10-21 00:19:10 UTC (rev 3100)
+++ FormEncode/trunk/docs/news.txt 2007-10-21 00:22:19 UTC (rev 3101)
@@ -40,6 +40,9 @@
* ``validators.Int`` takes ``min`` and ``max`` options (from Felix
Schwarz).
+* Make ``validators.DateConverter`` serialize dates properly (from
+ James Gardner).
+
0.7.1
-----
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2007-10-21 00:19:10 UTC (rev 3100)
+++ FormEncode/trunk/formencode/validators.py 2007-10-21 00:22:19 UTC (rev 3101)
@@ -1799,7 +1799,7 @@
'invalidDate': _('That is not a valid day (%(exception)s)'),
'unknownMonthName': _("Unknown month name: %(month)s"),
'invalidYear': _('Please enter a number for the year'),
- 'fourDigitYear': _('Please enter a four-digit year'),
+ 'fourDigitYear': _('Please enter a four-digit year after 1899'),
'wrongFormat': _('Please enter the date in the form %(format)s'),
}
@@ -1865,7 +1865,7 @@
year = year + 2000
if year >= 50 and year < 100:
year = year + 1900
- if year > 20 and year < 50:
+ if (year > 20 and year < 50) or (year>99 and year<1900):
raise Invalid(self.message('fourDigitYear', state),
year, state)
return year
@@ -1894,8 +1894,11 @@
def unconvert_day(self, value, state):
# @@ ib: double-check, improve
- return value.strftime("%m/%d/%Y")
-
+ if self.month_style == 'mm/dd/yyyy':
+ return value.strftime("%m/%d/%Y")
+ else:
+ return value.strftime("%d/%m/%Y")
+
def unconvert_month(self, value, state):
# @@ ib: double-check, improve
return value.strftime("%m/%Y")
|