summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMridul Dhall <mriduldhall@Mriduls-MacBook-Pro.local>2025-08-08 17:12:31 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-09-23 16:52:47 +0200
commitb67a36ec6f5895f3fa6147264bae55cb014fa2a7 (patch)
tree113a4c0c9a4cbeaafdc32005412278e50189035c
parent748551fea0b4e37231203a063356572a47e09efb (diff)
Fixed #36543 -- Fixed time formats for fr_CA.
Thanks Chris Anderson for the report.
-rw-r--r--django/conf/locale/fr_CA/formats.py6
-rw-r--r--tests/i18n/tests.py21
2 files changed, 24 insertions, 3 deletions
diff --git a/django/conf/locale/fr_CA/formats.py b/django/conf/locale/fr_CA/formats.py
index 4f1a017f16..ecb45f5bbb 100644
--- a/django/conf/locale/fr_CA/formats.py
+++ b/django/conf/locale/fr_CA/formats.py
@@ -3,12 +3,12 @@
# The *_FORMAT strings use the Django date format syntax,
# see https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = "j F Y" # 31 janvier 2024
-TIME_FORMAT = "H\xa0h\xa0i" # 13 h 40
-DATETIME_FORMAT = "j F Y, H\xa0h\xa0i" # 31 janvier 2024, 13 h 40
+TIME_FORMAT = "H\xa0\\h\xa0i" # 13 h 40
+DATETIME_FORMAT = "j F Y, H\xa0\\h\xa0i" # 31 janvier 2024, 13 h 40
YEAR_MONTH_FORMAT = "F Y"
MONTH_DAY_FORMAT = "j F"
SHORT_DATE_FORMAT = "Y-m-d"
-SHORT_DATETIME_FORMAT = "Y-m-d H\xa0h\xa0i"
+SHORT_DATETIME_FORMAT = "Y-m-d H\xa0\\h\xa0i"
FIRST_DAY_OF_WEEK = 0 # Dimanche
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index b4bdf160d6..aac56f5df4 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -1158,6 +1158,27 @@ class FormattingTests(SimpleTestCase):
),
)
+ def test_uncommon_locale_formats(self):
+ testcases = {
+ # French Canadian locale uses 'h' as time format seperator.
+ ("fr-ca", time_format, (self.t, "TIME_FORMAT")): "10\xa0h\xa015",
+ (
+ "fr-ca",
+ date_format,
+ (self.dt, "DATETIME_FORMAT"),
+ ): "31 décembre 2009, 20\xa0h\xa050",
+ (
+ "fr-ca",
+ date_format,
+ (self.dt, "SHORT_DATETIME_FORMAT"),
+ ): "2009-12-31 20\xa0h\xa050",
+ }
+ for testcase, expected in testcases.items():
+ locale, format_function, format_args = testcase
+ with self.subTest(locale=locale, expected=expected):
+ with translation.override(locale, deactivate=True):
+ self.assertEqual(expected, format_function(*format_args))
+
def test_sub_locales(self):
"""
Check if sublocales fall back to the main locale