mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Add support for New Zealand (en-nz) date/time formats (#5449)
- Implement en-NZ specific formatting in daterange.py - Create en_NZ/formats.py with NZ-compliant formats
This commit is contained in:
@@ -64,6 +64,16 @@ def daterange(df, dt, as_html=False):
|
||||
return format_html(base_format, _date(df, "j."), mark_safe(until.strip()), _date(dt, "j. F Y"))
|
||||
elif df.year == dt.year:
|
||||
return format_html(base_format, _date(df, "j. F"), until, _date(dt, "j. F Y"))
|
||||
elif lng == "en-nz":
|
||||
if df.year == dt.year and df.month == dt.month and df.day == dt.day:
|
||||
# Mon, 15 January 2024
|
||||
return format_html(base_format, _date(df, "D, j F Y"))
|
||||
elif df.year == dt.year and df.month == dt.month:
|
||||
# 1 – 3 January 2024
|
||||
return format_html(base_format, _date(df, "j"), until, _date(dt, "j F Y"))
|
||||
elif df.year == dt.year:
|
||||
# 1 January – 3 April 2024
|
||||
return format_html(base_format, _date(df, "j F"), until, _date(dt, "j F Y"))
|
||||
elif lng.startswith("en"):
|
||||
if df.year == dt.year and df.month == dt.month and df.day == dt.day:
|
||||
return format_html(base_format, _date(df, "D, N jS, Y"))
|
||||
|
||||
21
src/pretix/helpers/formats/en_NZ/__init__.py
Normal file
21
src/pretix/helpers/formats/en_NZ/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# This file is part of pretix (Community Edition).
|
||||
#
|
||||
# Copyright (C) 2014-2020 Raphael Michel and contributors
|
||||
# Copyright (C) 2020-2021 rami.io GmbH and contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
||||
# Public License as published by the Free Software Foundation in version 3 of the License.
|
||||
#
|
||||
# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are
|
||||
# applicable granting you additional permissions and placing additional restrictions on your usage of this software.
|
||||
# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive
|
||||
# this file, see <https://pretix.eu/about/en/license>.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
50
src/pretix/helpers/formats/en_NZ/formats.py
Normal file
50
src/pretix/helpers/formats/en_NZ/formats.py
Normal file
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# This file is part of pretix (Community Edition).
|
||||
#
|
||||
# Copyright (C) 2014-2020 Raphael Michel and contributors
|
||||
# Copyright (C) 2020-2021 rami.io GmbH and contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
||||
# Public License as published by the Free Software Foundation in version 3 of the License.
|
||||
#
|
||||
# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are
|
||||
# applicable granting you additional permissions and placing additional restrictions on your usage of this software.
|
||||
# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive
|
||||
# this file, see <https://pretix.eu/about/en/license>.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# Date according to https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
# Following NZ government guidance from https://www.digital.govt.nz/standards-and-guidance/design-and-ux/content-design-guidance/writing-style/numbers
|
||||
DATE_FORMAT = "j F Y" # 12 December 2015
|
||||
DATETIME_FORMAT = "j F Y, g:ia" # 12 December 2015, 5:30pm
|
||||
TIME_FORMAT = "g:ia" # 5:30pm
|
||||
YEAR_MONTH_FORMAT = "F Y" # December 2015
|
||||
MONTH_DAY_FORMAT = "j F" # 12 December
|
||||
SHORT_DATE_FORMAT = "j F Y" # same as DATE_FORMAT per guidance
|
||||
SHORT_DATETIME_FORMAT = "j F Y, g:ia"
|
||||
WEEKDAY_FORMAT = "l" # Monday
|
||||
WEEKDAY_DATE_FORMAT = "l, j F Y" # Friday, 23 November 2018
|
||||
WEEK_FORMAT = "\\W W, o" # ISO week: "W 52, 2024"
|
||||
WEEK_DAY_FORMAT = "D, j M" # Abbrev weekday and month: "Mon, 5 Feb"
|
||||
SHORT_MONTH_DAY_FORMAT = "j/n" # Numeric day/month: "5/2"
|
||||
|
||||
# Parsing inputs; keep d/m/Y and ISO
|
||||
DATE_INPUT_FORMATS = [
|
||||
"%d/%m/%Y",
|
||||
"%Y-%m-%d",
|
||||
"%d/%m/%y",
|
||||
]
|
||||
|
||||
TIME_INPUT_FORMATS = [
|
||||
"%I:%M%p", # 5:30pm
|
||||
"%H:%M:%S",
|
||||
"%H:%M:%S.%f",
|
||||
"%H:%M",
|
||||
]
|
||||
Reference in New Issue
Block a user