Loading django/conf/global_settings.py +1 −0 Original line number Diff line number Diff line Loading @@ -365,6 +365,7 @@ DATE_INPUT_FORMATS = ( # * Note that these format strings are different from the ones to display dates TIME_INPUT_FORMATS = ( '%H:%M:%S', # '14:30:59' '%H:%M:%S.%f', # '14:30:59.000200' '%H:%M', # '14:30' ) Loading django/utils/formats.py +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ _format_modules_cache = {} ISO_INPUT_FORMATS = { 'DATE_INPUT_FORMATS': ('%Y-%m-%d',), 'TIME_INPUT_FORMATS': ('%H:%M:%S', '%H:%M'), 'TIME_INPUT_FORMATS': ('%H:%M:%S', '%H:%M:%S.%f', '%H:%M'), 'DATETIME_INPUT_FORMATS': ( '%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', Loading docs/ref/settings.txt +5 −0 Original line number Diff line number Diff line Loading @@ -1731,6 +1731,7 @@ Default:: ( '%H:%M:%S', # '14:30:59' '%H:%M:%S.%f', # '14:30:59.000200' '%H:%M', # '14:30' ) Loading @@ -1744,6 +1745,10 @@ precedence and will be applied instead. See also :setting:`DATE_INPUT_FORMATS` and :setting:`DATETIME_INPUT_FORMATS`. .. versionchanged:: 1.6 Input format with microseconds has been added. .. _datetime: http://docs.python.org/library/datetime.html#strftime-strptime-behavior .. setting:: TIME_ZONE Loading tests/forms_tests/tests/input_formats.py +6 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,8 @@ from django.test import SimpleTestCase @override_settings(TIME_INPUT_FORMATS=["%I:%M:%S %p", "%I:%M %p"], USE_L10N=True) class LocalizedTimeTests(SimpleTestCase): def setUp(self): # nl/formats.py has customized TIME_INPUT_FORMATS # nl/formats.py has customized TIME_INPUT_FORMATS: # ('%H:%M:%S', '%H.%M:%S', '%H.%M', '%H:%M') activate('nl') def tearDown(self): Loading Loading @@ -37,6 +38,10 @@ class LocalizedTimeTests(SimpleTestCase): text = f.widget._format_value(result) self.assertEqual(text, "13:30:00") # ISO formats are accepted, even if not specified in formats.py result = f.clean('13:30:05.000155') self.assertEqual(result, time(13,30,5,155)) def test_localized_timeField(self): "Localized TimeFields act as unlocalized widgets" f = forms.TimeField(localize=True) Loading Loading
django/conf/global_settings.py +1 −0 Original line number Diff line number Diff line Loading @@ -365,6 +365,7 @@ DATE_INPUT_FORMATS = ( # * Note that these format strings are different from the ones to display dates TIME_INPUT_FORMATS = ( '%H:%M:%S', # '14:30:59' '%H:%M:%S.%f', # '14:30:59.000200' '%H:%M', # '14:30' ) Loading
django/utils/formats.py +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ _format_modules_cache = {} ISO_INPUT_FORMATS = { 'DATE_INPUT_FORMATS': ('%Y-%m-%d',), 'TIME_INPUT_FORMATS': ('%H:%M:%S', '%H:%M'), 'TIME_INPUT_FORMATS': ('%H:%M:%S', '%H:%M:%S.%f', '%H:%M'), 'DATETIME_INPUT_FORMATS': ( '%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', Loading
docs/ref/settings.txt +5 −0 Original line number Diff line number Diff line Loading @@ -1731,6 +1731,7 @@ Default:: ( '%H:%M:%S', # '14:30:59' '%H:%M:%S.%f', # '14:30:59.000200' '%H:%M', # '14:30' ) Loading @@ -1744,6 +1745,10 @@ precedence and will be applied instead. See also :setting:`DATE_INPUT_FORMATS` and :setting:`DATETIME_INPUT_FORMATS`. .. versionchanged:: 1.6 Input format with microseconds has been added. .. _datetime: http://docs.python.org/library/datetime.html#strftime-strptime-behavior .. setting:: TIME_ZONE Loading
tests/forms_tests/tests/input_formats.py +6 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,8 @@ from django.test import SimpleTestCase @override_settings(TIME_INPUT_FORMATS=["%I:%M:%S %p", "%I:%M %p"], USE_L10N=True) class LocalizedTimeTests(SimpleTestCase): def setUp(self): # nl/formats.py has customized TIME_INPUT_FORMATS # nl/formats.py has customized TIME_INPUT_FORMATS: # ('%H:%M:%S', '%H.%M:%S', '%H.%M', '%H:%M') activate('nl') def tearDown(self): Loading Loading @@ -37,6 +38,10 @@ class LocalizedTimeTests(SimpleTestCase): text = f.widget._format_value(result) self.assertEqual(text, "13:30:00") # ISO formats are accepted, even if not specified in formats.py result = f.clean('13:30:05.000155') self.assertEqual(result, time(13,30,5,155)) def test_localized_timeField(self): "Localized TimeFields act as unlocalized widgets" f = forms.TimeField(localize=True) Loading