From 1d9577a192bd64d95a5dddab1637123aace8b44d Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Sat, 11 Feb 2023 17:39:36 -0800 Subject: [PATCH] Sync moment and Django formats for PT and TR Fixes #498 and #532 --- babybuddy/formats/pt/__init__.py | 0 babybuddy/formats/pt/formats.py | 11 +++++++++++ babybuddy/formats/tr/__init__.py | 0 babybuddy/formats/tr/formats.py | 9 +++++++++ babybuddy/settings/base.py | 2 ++ 5 files changed, 22 insertions(+) create mode 100644 babybuddy/formats/pt/__init__.py create mode 100644 babybuddy/formats/pt/formats.py create mode 100644 babybuddy/formats/tr/__init__.py create mode 100644 babybuddy/formats/tr/formats.py diff --git a/babybuddy/formats/pt/__init__.py b/babybuddy/formats/pt/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/babybuddy/formats/pt/formats.py b/babybuddy/formats/pt/formats.py new file mode 100644 index 00000000..8b32c55e --- /dev/null +++ b/babybuddy/formats/pt/formats.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +from django.conf.locale.pt import formats + +# Limit datetime input formats to those support by moment. +formats_supported = list( + filter( + lambda dt_format: not dt_format.startswith("%Y-%m-%d"), + formats.DATETIME_INPUT_FORMATS, + ) +) +DATETIME_INPUT_FORMATS = formats_supported diff --git a/babybuddy/formats/tr/__init__.py b/babybuddy/formats/tr/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/babybuddy/formats/tr/formats.py b/babybuddy/formats/tr/formats.py new file mode 100644 index 00000000..795d929e --- /dev/null +++ b/babybuddy/formats/tr/formats.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- +from django.conf.locale.tr import formats + +# Add formats supported by moment. +DATETIME_INPUT_FORMATS = [ + "%d.%m.%Y %H:%M:%S", + "%d.%m.%Y %H:%M", + *formats.DATETIME_INPUT_FORMATS, +] diff --git a/babybuddy/settings/base.py b/babybuddy/settings/base.py index a388420f..57a7da9a 100644 --- a/babybuddy/settings/base.py +++ b/babybuddy/settings/base.py @@ -198,6 +198,8 @@ LANGUAGES = [ USE_L10N = True +FORMAT_MODULE_PATH = ["babybuddy.formats"] + # Custom setting that can be used to override the locale-based time set by # USE_L10N _for specific locales_ to use 24-hour format. In order for this to # work with a given locale it must be set at the FORMAT_MODULE_PATH with