Skip to content

Commit b67a36e

Browse files
Mridul Dhallsarahboyce
authored andcommitted
Fixed #36543 -- Fixed time formats for fr_CA.
Thanks Chris Anderson for the report.
1 parent 748551f commit b67a36e

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

django/conf/locale/fr_CA/formats.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# The *_FORMAT strings use the Django date format syntax,
44
# see https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
55
DATE_FORMAT = "j F Y" # 31 janvier 2024
6-
TIME_FORMAT = "H\xa0h\xa0i" # 13 h 40
7-
DATETIME_FORMAT = "j F Y, H\xa0h\xa0i" # 31 janvier 2024, 13 h 40
6+
TIME_FORMAT = "H\xa0\\h\xa0i" # 13 h 40
7+
DATETIME_FORMAT = "j F Y, H\xa0\\h\xa0i" # 31 janvier 2024, 13 h 40
88
YEAR_MONTH_FORMAT = "F Y"
99
MONTH_DAY_FORMAT = "j F"
1010
SHORT_DATE_FORMAT = "Y-m-d"
11-
SHORT_DATETIME_FORMAT = "Y-m-d H\xa0h\xa0i"
11+
SHORT_DATETIME_FORMAT = "Y-m-d H\xa0\\h\xa0i"
1212
FIRST_DAY_OF_WEEK = 0 # Dimanche
1313

1414
# The *_INPUT_FORMATS strings use the Python strftime format syntax,

tests/i18n/tests.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,27 @@ def test_l10n_enabled(self):
11581158
),
11591159
)
11601160

1161+
def test_uncommon_locale_formats(self):
1162+
testcases = {
1163+
# French Canadian locale uses 'h' as time format seperator.
1164+
("fr-ca", time_format, (self.t, "TIME_FORMAT")): "10\xa0h\xa015",
1165+
(
1166+
"fr-ca",
1167+
date_format,
1168+
(self.dt, "DATETIME_FORMAT"),
1169+
): "31 décembre 2009, 20\xa0h\xa050",
1170+
(
1171+
"fr-ca",
1172+
date_format,
1173+
(self.dt, "SHORT_DATETIME_FORMAT"),
1174+
): "2009-12-31 20\xa0h\xa050",
1175+
}
1176+
for testcase, expected in testcases.items():
1177+
locale, format_function, format_args = testcase
1178+
with self.subTest(locale=locale, expected=expected):
1179+
with translation.override(locale, deactivate=True):
1180+
self.assertEqual(expected, format_function(*format_args))
1181+
11611182
def test_sub_locales(self):
11621183
"""
11631184
Check if sublocales fall back to the main locale

0 commit comments

Comments
 (0)