Refs #13339 -- Disable %b/%B-based locale datetime input formats, and document that they are problematic.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13039 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2010-04-28 11:27:38 +00:00
parent cae4401a01
commit 4e0aa65d16
12 changed files with 47 additions and 41 deletions

View File

@ -13,7 +13,7 @@ FIRST_DAY_OF_WEEK = 1 # Monday
DATE_INPUT_FORMATS = ( DATE_INPUT_FORMATS = (
'%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06' '%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06'
'%Y-%m-%d', '%y-%m-%d', # '2006-10-25', '06-10-25' '%Y-%m-%d', '%y-%m-%d', # '2006-10-25', '06-10-25'
'%d. %B %Y', '%d. %b. %Y', # '25. October 2006', '25. Oct. 2006' # '%d. %B %Y', '%d. %b. %Y', # '25. October 2006', '25. Oct. 2006'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59' '%H:%M:%S', # '14:30:59'

View File

@ -13,7 +13,7 @@ FIRST_DAY_OF_WEEK = 1 # Monday
DATE_INPUT_FORMATS = ( DATE_INPUT_FORMATS = (
'%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06' '%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06'
'%Y-%m-%d', '%y-%m-%d', # '2006-10-25', '06-10-25' '%Y-%m-%d', '%y-%m-%d', # '2006-10-25', '06-10-25'
'%d. %B %Y', '%d. %b. %Y', # '25. October 2006', '25. Oct. 2006' # '%d. %B %Y', '%d. %b. %Y', # '25. October 2006', '25. Oct. 2006'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59' '%H:%M:%S', # '14:30:59'

View File

@ -12,10 +12,10 @@ SHORT_DATETIME_FORMAT = 'm/d/Y P'
FIRST_DAY_OF_WEEK = 0 # Sunday FIRST_DAY_OF_WEEK = 0 # Sunday
DATE_INPUT_FORMATS = ( DATE_INPUT_FORMATS = (
'%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06' '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
'%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006' # '%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006'
'%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006' # '%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006'
'%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006' # '%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006'
'%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006' # '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59' '%H:%M:%S', # '14:30:59'

View File

@ -14,7 +14,7 @@ DATE_INPUT_FORMATS = (
'%d/%m/%Y', '%d/%m/%y', # '25/10/2006', '25/10/06' '%d/%m/%Y', '%d/%m/%y', # '25/10/2006', '25/10/06'
'%d.%m.%Y', '%d.%m.%y', # Swiss (fr_CH), '25.10.2006', '25.10.06' '%d.%m.%Y', '%d.%m.%y', # Swiss (fr_CH), '25.10.2006', '25.10.06'
'%Y-%m-%d', '%y-%m-%d', # '2006-10-25', '06-10-25' '%Y-%m-%d', '%y-%m-%d', # '2006-10-25', '06-10-25'
'%d %B %Y', '%d %b %Y', # '25 octobre 2006', '25 oct. 2006' # '%d %B %Y', '%d %b %Y', # '25 octobre 2006', '25 oct. 2006'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59' '%H:%M:%S', # '14:30:59'

View File

@ -12,9 +12,9 @@ SHORT_DATETIME_FORMAT = 'j.M.Y H:i:s'
FIRST_DAY_OF_WEEK = 1 # (Monday) FIRST_DAY_OF_WEEK = 1 # (Monday)
DATE_INPUT_FORMATS = ( DATE_INPUT_FORMATS = (
'%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06' '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
'%d %b %Y', '%d %b, %Y', '%d %b. %Y', # '25 Oct 2006', '25 Oct, 2006', '25 Oct. 2006' # '%d %b %Y', '%d %b, %Y', '%d %b. %Y', # '25 Oct 2006', '25 Oct, 2006', '25 Oct. 2006'
'%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006' # '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006'
'%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06' # '%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59' '%H:%M:%S', # '14:30:59'

View File

@ -9,13 +9,13 @@ YEAR_MONTH_FORMAT = 'Y년 F월'
MONTH_DAY_FORMAT = 'F월 j일' MONTH_DAY_FORMAT = 'F월 j일'
SHORT_DATE_FORMAT = 'Y-n-j.' SHORT_DATE_FORMAT = 'Y-n-j.'
SHORT_DATETIME_FORMAT = 'Y-n-j H:i' SHORT_DATETIME_FORMAT = 'Y-n-j H:i'
# FIRST_DAY_OF_WEEK = # FIRST_DAY_OF_WEEK =
DATE_INPUT_FORMATS = ( DATE_INPUT_FORMATS = (
'%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06' '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
'%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006' # '%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006'
'%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006' # '%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006'
'%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006' # '%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006'
'%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006' # '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006'
'%Y년 %m월 %d', # '2006년 10월 25일', with localized suffix. '%Y년 %m월 %d', # '2006년 10월 25일', with localized suffix.
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (

View File

@ -12,8 +12,8 @@ SHORT_DATETIME_FORMAT = 'j-n-Y H:i' # '20-1-2009 15:23'
FIRST_DAY_OF_WEEK = 1 # Monday (in Dutch 'maandag') FIRST_DAY_OF_WEEK = 1 # Monday (in Dutch 'maandag')
DATE_INPUT_FORMATS = ( DATE_INPUT_FORMATS = (
'%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d', # '20-01-2009', '20-01-09', '2009-01-20' '%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d', # '20-01-2009', '20-01-09', '2009-01-20'
'%d %b %Y', '%d %b %y', # '20 jan 2009', '20 jan 09' # '%d %b %Y', '%d %b %y', # '20 jan 2009', '20 jan 09'
'%d %B %Y', '%d %B %y', # '20 januari 2009', '20 januari 09' # '%d %B %Y', '%d %B %y', # '20 januari 2009', '20 januari 09'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '15:23:35' '%H:%M:%S', # '15:23:35'
@ -24,24 +24,24 @@ TIME_INPUT_FORMATS = (
DATETIME_INPUT_FORMATS = ( DATETIME_INPUT_FORMATS = (
# With time in %H:%M:%S : # With time in %H:%M:%S :
'%d-%m-%Y %H:%M:%S', '%d-%m-%y %H:%M:%S', '%Y-%m-%d %H:%M:%S', # '20-01-2009 15:23:35', '20-01-09 15:23:35', '2009-01-20 15:23:35' '%d-%m-%Y %H:%M:%S', '%d-%m-%y %H:%M:%S', '%Y-%m-%d %H:%M:%S', # '20-01-2009 15:23:35', '20-01-09 15:23:35', '2009-01-20 15:23:35'
'%d %b %Y %H:%M:%S', '%d %b %y %H:%M:%S', # '20 jan 2009 15:23:35', '20 jan 09 15:23:35' # '%d %b %Y %H:%M:%S', '%d %b %y %H:%M:%S', # '20 jan 2009 15:23:35', '20 jan 09 15:23:35'
'%d %B %Y %H:%M:%S', '%d %B %y %H:%M:%S', # '20 januari 2009 15:23:35', '20 januari 2009 15:23:35' # '%d %B %Y %H:%M:%S', '%d %B %y %H:%M:%S', # '20 januari 2009 15:23:35', '20 januari 2009 15:23:35'
# With time in %H.%M:%S : # With time in %H.%M:%S :
'%d-%m-%Y %H.%M:%S', '%d-%m-%y %H.%M:%S', # '20-01-2009 15.23:35', '20-01-09 15.23:35' '%d-%m-%Y %H.%M:%S', '%d-%m-%y %H.%M:%S', # '20-01-2009 15.23:35', '20-01-09 15.23:35'
'%d %b %Y %H.%M:%S', '%d %b %y %H.%M:%S', # '20 jan 2009 15.23:35', '20 jan 09 15.23:35' # '%d %b %Y %H.%M:%S', '%d %b %y %H.%M:%S', # '20 jan 2009 15.23:35', '20 jan 09 15.23:35'
'%d %B %Y %H.%M:%S', '%d %B %y %H.%M:%S', # '20 januari 2009 15.23:35', '20 januari 2009 15.23:35' # '%d %B %Y %H.%M:%S', '%d %B %y %H.%M:%S', # '20 januari 2009 15.23:35', '20 januari 2009 15.23:35'
# With time in %H:%M : # With time in %H:%M :
'%d-%m-%Y %H:%M', '%d-%m-%y %H:%M', '%Y-%m-%d %H:%M', # '20-01-2009 15:23', '20-01-09 15:23', '2009-01-20 15:23' '%d-%m-%Y %H:%M', '%d-%m-%y %H:%M', '%Y-%m-%d %H:%M', # '20-01-2009 15:23', '20-01-09 15:23', '2009-01-20 15:23'
'%d %b %Y %H:%M', '%d %b %y %H:%M', # '20 jan 2009 15:23', '20 jan 09 15:23' # '%d %b %Y %H:%M', '%d %b %y %H:%M', # '20 jan 2009 15:23', '20 jan 09 15:23'
'%d %B %Y %H:%M', '%d %B %y %H:%M', # '20 januari 2009 15:23', '20 januari 2009 15:23' # '%d %B %Y %H:%M', '%d %B %y %H:%M', # '20 januari 2009 15:23', '20 januari 2009 15:23'
# With time in %H.%M : # With time in %H.%M :
'%d-%m-%Y %H.%M', '%d-%m-%y %H.%M', # '20-01-2009 15.23', '20-01-09 15.23' '%d-%m-%Y %H.%M', '%d-%m-%y %H.%M', # '20-01-2009 15.23', '20-01-09 15.23'
'%d %b %Y %H.%M', '%d %b %y %H.%M', # '20 jan 2009 15.23', '20 jan 09 15.23' # '%d %b %Y %H.%M', '%d %b %y %H.%M', # '20 jan 2009 15.23', '20 jan 09 15.23'
'%d %B %Y %H.%M', '%d %B %y %H.%M', # '20 januari 2009 15.23', '20 januari 2009 15.23' # '%d %B %Y %H.%M', '%d %B %y %H.%M', # '20 januari 2009 15.23', '20 januari 2009 15.23'
# Without time : # Without time :
'%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d', # '20-01-2009', '20-01-09', '2009-01-20' '%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d', # '20-01-2009', '20-01-09', '2009-01-20'
'%d %b %Y', '%d %b %y', # '20 jan 2009', '20 jan 09' # '%d %b %Y', '%d %b %y', # '20 jan 2009', '20 jan 09'
'%d %B %Y', '%d %B %y', # '20 januari 2009', '20 januari 2009' # '%d %B %Y', '%d %B %y', # '20 januari 2009', '20 januari 2009'
) )
DECIMAL_SEPARATOR = ',' DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = '.' THOUSAND_SEPARATOR = '.'

View File

@ -8,10 +8,10 @@ SHORT_DATETIME_FORMAT = 'd.m.Y H:i'
FIRST_DAY_OF_WEEK = 1 # Monday FIRST_DAY_OF_WEEK = 1 # Monday
DATE_INPUT_FORMATS = ( DATE_INPUT_FORMATS = (
'%Y-%m-%d', '%j.%m.%Y', '%j.%m.%y', # '2006-10-25', '25.10.2006', '25.10.06' '%Y-%m-%d', '%j.%m.%Y', '%j.%m.%y', # '2006-10-25', '25.10.2006', '25.10.06'
'%Y-%m-%j', # '2006-10-25', '%Y-%m-%j', # '2006-10-25',
'%j. %b %Y', '%j %b %Y', # '25. okt 2006', '25 okt 2006' # '%j. %b %Y', '%j %b %Y', # '25. okt 2006', '25 okt 2006'
'%j. %b. %Y', '%j %b. %Y', # '25. okt. 2006', '25 okt. 2006' # '%j. %b. %Y', '%j %b. %Y', # '25. okt. 2006', '25 okt. 2006'
'%j. %B %Y', '%j %B %Y', # '25. oktober 2006', '25 oktober 2006' # '%j. %B %Y', '%j %B %Y', # '25. oktober 2006', '25 oktober 2006'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59' '%H:%M:%S', # '14:30:59'

View File

@ -12,8 +12,8 @@ SHORT_DATETIME_FORMAT = 'd/m/Y H:i'
FIRST_DAY_OF_WEEK = 0 # Sunday FIRST_DAY_OF_WEEK = 0 # Sunday
DATE_INPUT_FORMATS = ( DATE_INPUT_FORMATS = (
'%Y-%m-%d', '%d/%m/%Y', '%d/%m/%y', # '2006-10-25', '25/10/2006', '25/10/06' '%Y-%m-%d', '%d/%m/%Y', '%d/%m/%y', # '2006-10-25', '25/10/2006', '25/10/06'
'%d de %b de %Y', '%d de %b, %Y', # '25 de Out de 2006', '25 Out, 2006' # '%d de %b de %Y', '%d de %b, %Y', # '25 de Out de 2006', '25 Out, 2006'
'%d de %B de %Y', '%d de %B, %Y', # '25 de Outubro de 2006', '25 de Outubro, 2006' # '%d de %B de %Y', '%d de %B, %Y', # '25 de Outubro de 2006', '25 de Outubro, 2006'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59' '%H:%M:%S', # '14:30:59'

View File

@ -14,9 +14,9 @@ DATE_INPUT_FORMATS = (
'%Y-%m-%d', # '2006-10-25' '%Y-%m-%d', # '2006-10-25'
'%d.%m.%Y.', '%d.%m.%y.', # '25.10.2006.', '25.10.06.' '%d.%m.%Y.', '%d.%m.%y.', # '25.10.2006.', '25.10.06.'
'%d. %m. %Y.', '%d. %m. %y.', # '25. 10. 2006.', '25. 10. 06.' '%d. %m. %Y.', '%d. %m. %y.', # '25. 10. 2006.', '25. 10. 06.'
'%d. %b %y.', '%d. %B %y.', # '25. Oct 06.', '25. October 06.' # '%d. %b %y.', '%d. %B %y.', # '25. Oct 06.', '25. October 06.'
'%d. %b \'%y.', '%d. %B \'%y.', # '25. Oct '06.', '25. October '06.' # '%d. %b \'%y.', '%d. %B \'%y.', # '25. Oct '06.', '25. October '06.'
'%d. %b %Y.', '%d. %B %Y.', # '25. Oct 2006.', '25. October 2006.' # '%d. %b %Y.', '%d. %B %Y.', # '25. Oct 2006.', '25. October 2006.'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59' '%H:%M:%S', # '14:30:59'

View File

@ -14,9 +14,9 @@ DATE_INPUT_FORMATS = (
'%Y-%m-%d', # '2006-10-25' '%Y-%m-%d', # '2006-10-25'
'%d.%m.%Y.', '%d.%m.%y.', # '25.10.2006.', '25.10.06.' '%d.%m.%Y.', '%d.%m.%y.', # '25.10.2006.', '25.10.06.'
'%d. %m. %Y.', '%d. %m. %y.', # '25. 10. 2006.', '25. 10. 06.' '%d. %m. %Y.', '%d. %m. %y.', # '25. 10. 2006.', '25. 10. 06.'
'%d. %b %y.', '%d. %B %y.', # '25. Oct 06.', '25. October 06.' # '%d. %b %y.', '%d. %B %y.', # '25. Oct 06.', '25. October 06.'
'%d. %b \'%y.', '%d. %B \'%y.', # '25. Oct '06.', '25. October '06.' # '%d. %b \'%y.', '%d. %B \'%y.', # '25. Oct '06.', '25. October '06.'
'%d. %b %Y.', '%d. %B %Y.', # '25. Oct 2006.', '25. October 2006.' # '%d. %b %Y.', '%d. %B %Y.', # '25. Oct 2006.', '25. October 2006.'
) )
TIME_INPUT_FORMATS = ( TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59' '%H:%M:%S', # '14:30:59'

View File

@ -265,8 +265,14 @@ current locale.
Django will also use localized formats when parsing data in forms. That means Django will also use localized formats when parsing data in forms. That means
Django uses different formats for different locales when guessing the format Django uses different formats for different locales when guessing the format
used by the user when inputting data on forms. Note that Django uses different used by the user when inputting data on forms.
formats for displaying data, and for parsing it.
.. note::
Django uses different formats for displaying data to those it uses for
parsing data. Most notably, the formats for parsing dates can't use the
``%a`` (abbreviated weekday name), ``%A`` (full weekday name),
``%b`` (abbreviated month name), ``%B`` (full month name),
or ``%p`` (AM/PM).
To enable a form field to localize input and output data simply use its To enable a form field to localize input and output data simply use its
``localize`` argument:: ``localize`` argument::