From 0c0d4baf41d24f5de92d3d0c35b379235dbd0ba0 Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Tue, 26 Oct 2021 19:36:31 -0700 Subject: [PATCH] Combine `en` and `en_GB` date input formats --- babybuddy/formats/en/formats.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/babybuddy/formats/en/formats.py b/babybuddy/formats/en/formats.py index 30a2c49b..bc4eef83 100644 --- a/babybuddy/formats/en/formats.py +++ b/babybuddy/formats/en/formats.py @@ -1,5 +1,6 @@ from django.conf import settings -from django.conf.locale.en import formats +from django.conf.locale.en import formats as formats_us +from django.conf.locale.en_GB import formats as formats_gb # Override the regular locale settings to support 24 hour time. if settings.USE_24_HOUR_TIME_FORMAT: @@ -22,5 +23,12 @@ else: # only work with the locale format locale specified by this file. SHORT_MONTH_DAY_FORMAT = 'M j' +# Combine en_US (en) and en_GB formats. This seems to be necessary because when +# an en language variation is used this file is still loaded and there is no +# way to implement e.g. an en_US format. Combining these formats allows the app +# to support both en (en_US) and en_GB without enforcing US-centric input +# formats on users with a en_GB setting. +formats = formats_us.DATETIME_INPUT_FORMATS + formats_gb.DATETIME_INPUT_FORMATS + # Append all other input formats from the base locale. -DATETIME_INPUT_FORMATS = CUSTOM_INPUT_FORMATS + formats.DATETIME_INPUT_FORMATS +DATETIME_INPUT_FORMATS = CUSTOM_INPUT_FORMATS + formats