forked from CGM_Public/pretix_original
Add short option to get_date_*_display
This commit is contained in:
@@ -65,7 +65,7 @@ class EventMixin:
|
|||||||
"SHORT_DATETIME_FORMAT" if self.settings.show_times else "DATE_FORMAT"
|
"SHORT_DATETIME_FORMAT" if self.settings.show_times else "DATE_FORMAT"
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_date_from_display(self, tz=None, show_times=True) -> str:
|
def get_date_from_display(self, tz=None, show_times=True, short=False) -> str:
|
||||||
"""
|
"""
|
||||||
Returns a formatted string containing the start date of the event with respect
|
Returns a formatted string containing the start date of the event with respect
|
||||||
to the current locale and to the ``show_times`` setting.
|
to the current locale and to the ``show_times`` setting.
|
||||||
@@ -73,7 +73,7 @@ class EventMixin:
|
|||||||
tz = tz or self.timezone
|
tz = tz or self.timezone
|
||||||
return _date(
|
return _date(
|
||||||
self.date_from.astimezone(tz),
|
self.date_from.astimezone(tz),
|
||||||
"DATETIME_FORMAT" if self.settings.show_times and show_times else "DATE_FORMAT"
|
("SHORT_" if short else "") + ("DATETIME_FORMAT" if self.settings.show_times and show_times else "DATE_FORMAT")
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_time_from_display(self, tz=None) -> str:
|
def get_time_from_display(self, tz=None) -> str:
|
||||||
@@ -86,7 +86,7 @@ class EventMixin:
|
|||||||
self.date_from.astimezone(tz), "TIME_FORMAT"
|
self.date_from.astimezone(tz), "TIME_FORMAT"
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_date_to_display(self, tz=None) -> str:
|
def get_date_to_display(self, tz=None, short=False) -> str:
|
||||||
"""
|
"""
|
||||||
Returns a formatted string containing the start date of the event with respect
|
Returns a formatted string containing the start date of the event with respect
|
||||||
to the current locale and to the ``show_times`` setting. Returns an empty string
|
to the current locale and to the ``show_times`` setting. Returns an empty string
|
||||||
@@ -97,7 +97,7 @@ class EventMixin:
|
|||||||
return ""
|
return ""
|
||||||
return _date(
|
return _date(
|
||||||
self.date_to.astimezone(tz),
|
self.date_to.astimezone(tz),
|
||||||
"DATETIME_FORMAT" if self.settings.show_times else "DATE_FORMAT"
|
("SHORT_" if short else "") + ("DATETIME_FORMAT" if self.settings.show_times else "DATE_FORMAT")
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_date_range_display(self, tz=None, force_show_end=False) -> str:
|
def get_date_range_display(self, tz=None, force_show_end=False) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user