diff --git a/inginious/frontend/accessible_time.py b/inginious/frontend/accessible_time.py index f0796c85d..b5269a5fa 100644 --- a/inginious/frontend/accessible_time.py +++ b/inginious/frontend/accessible_time.py @@ -22,9 +22,9 @@ def parse_date(date, default=None): raise Exception("Empty date given to AccessibleTime") if date == "0001-01-01 00:00:00": - return datetime.min + return datetime.min.replace(tzinfo=timezone.utc) if date == "9999-12-31 23:59:59": - return datetime.max.replace(microsecond=0) + return datetime.max.replace(microsecond=0, tzinfo=timezone.utc) for format_type in ["%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M", "%Y-%m-%d %H", "%Y-%m-%d", "%d/%m/%Y %H:%M:%S", "%d/%m/%Y %H:%M", "%d/%m/%Y %H", "%d/%m/%Y"]: @@ -46,8 +46,8 @@ def __init__(self, period): Can be a boolean, None or string if using the legacy format "start/soft_end/end" """ - self.max = datetime.max.replace(microsecond=0) - self.min = datetime.min.replace() + self.max = datetime.max.replace(microsecond=0, tzinfo=timezone.utc) + self.min = datetime.min.replace(tzinfo=timezone.utc) if not isinstance(period, (dict, str, bool, type(None))): # add None check raise Exception("Wrong period given to AccessibleTime") @@ -178,3 +178,11 @@ def get_string_dict(self): "soft_end": self.string_date(self._soft_end), "end": self.string_date(self._end) } + + def string_max(self): + """ Returns the max date as a string """ + return self.string_date(self.max) + + def string_min(self): + """ Returns the min date as a string """ + return self.string_date(self.min) \ No newline at end of file diff --git a/inginious/frontend/templates/task_dispensers_admin/config_items/accessibility.html b/inginious/frontend/templates/task_dispensers_admin/config_items/accessibility.html index ad9caf633..8270c3422 100644 --- a/inginious/frontend/templates/task_dispensers_admin/config_items/accessibility.html +++ b/inginious/frontend/templates/task_dispensers_admin/config_items/accessibility.html @@ -97,6 +97,7 @@