1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #9762 -- Made DateFormat.r() locale-independent.

Thanks to Antonio Melé for the original report all those years ago
and to all the contributors who helped along the way.
This commit is contained in:
Baptiste Mispelon
2019-11-21 20:34:58 +01:00
committed by Mariusz Felisiak
parent 76ec032712
commit 8929afb8ec
2 changed files with 19 additions and 3 deletions

View File

@@ -131,7 +131,7 @@ class DateFormatTests(SimpleTestCase):
if TZ_SUPPORT:
self.assertEqual(dateformat.format(my_birthday, 'O'), '+0100')
self.assertEqual(dateformat.format(my_birthday, 'r'), 'Sun, 8 Jul 1979 22:00:00 +0100')
self.assertEqual(dateformat.format(my_birthday, 'r'), 'Sun, 08 Jul 1979 22:00:00 +0100')
self.assertEqual(dateformat.format(my_birthday, 'T'), 'CET')
self.assertEqual(dateformat.format(my_birthday, 'e'), '')
self.assertEqual(dateformat.format(aware_dt, 'e'), '-0330')
@@ -156,3 +156,12 @@ class DateFormatTests(SimpleTestCase):
)
with self.assertRaisesMessage(TypeError, msg):
dateformat.format(my_birthday, specifier)
def test_r_format_with_non_en_locale(self):
# Changing the locale doesn't change the "r" format.
dt = datetime(1979, 7, 8, 22, 00)
with translation.override('fr'):
self.assertEqual(
dateformat.format(dt, 'r'),
'Sun, 08 Jul 1979 22:00:00 +0100',
)