mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
* Upgrade Django to 3.0 and other dependencies to recent versions * Fix otp version contsraint * Remove six dependency * Resolve some warnings * Fix failing tests * Update django-countries * Resolve all RemovedInDjango31Warnings in test suite * Run isort * Fix import * Update PostgreSQL version on travis
35 lines
1.7 KiB
Python
35 lines
1.7 KiB
Python
from django.template.defaultfilters import date as _date
|
||
from django.utils.translation import get_language, gettext_lazy as _
|
||
|
||
|
||
def daterange(df, dt):
|
||
lng = get_language()
|
||
|
||
if lng.startswith("de"):
|
||
if df.year == dt.year and df.month == dt.month and df.day == dt.day:
|
||
return "{}".format(_date(df, "j. F Y"))
|
||
elif df.year == dt.year and df.month == dt.month:
|
||
return "{}.–{}".format(_date(df, "j"), _date(dt, "j. F Y"))
|
||
elif df.year == dt.year:
|
||
return "{} – {}".format(_date(df, "j. F"), _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(_date(df, "N jS, Y"))
|
||
elif df.year == dt.year and df.month == dt.month:
|
||
return "{} – {}".format(_date(df, "N jS"), _date(dt, "jS, Y"))
|
||
elif df.year == dt.year:
|
||
return "{} – {}".format(_date(df, "N jS"), _date(dt, "N jS, Y"))
|
||
elif lng.startswith("es"):
|
||
if df.year == dt.year and df.month == dt.month and df.day == dt.day:
|
||
return "{}".format(_date(df, "DATE_FORMAT"))
|
||
elif df.year == dt.year and df.month == dt.month:
|
||
return "{} - {} de {} de {}".format(_date(df, "j"), _date(dt, "j"), _date(dt, "F"), _date(dt, "Y"))
|
||
elif df.year == dt.year:
|
||
return "{} de {} - {} de {} de {}".format(_date(df, "j"), _date(df, "F"), _date(dt, "j"), _date(dt, "F"), _date(dt, "Y"))
|
||
|
||
if df.year == dt.year and df.month == dt.month and df.day == dt.day:
|
||
return _date(df, "DATE_FORMAT")
|
||
return _("{date_from} – {date_to}").format(
|
||
date_from=_date(df, "DATE_FORMAT"), date_to=_date(dt, "DATE_FORMAT")
|
||
)
|