diff --git a/base-config.yaml b/base-config.yaml index f868c3f455101924182a43830f8f874495504df5..a42dbdcd3abb5c69aa31c5b37475991334089831 100644 --- a/base-config.yaml +++ b/base-config.yaml @@ -3,3 +3,6 @@ base_command: - remind - reminder + +# Default timezone for users who did not set one +timezone: 'UTC' diff --git a/reminder/util.py b/reminder/util.py index a29992a9dabd442397f420a81d6e662db09f1830..99c291a80a41f7b1d4785e97eb06f1bdf030ddb2 100644 --- a/reminder/util.py +++ b/reminder/util.py @@ -35,6 +35,7 @@ if TYPE_CHECKING: class Config(BaseProxyConfig): def do_update(self, helper: ConfigUpdateHelper) -> None: helper.copy("base_command") + helper.copy("timezone") class DateArgument(Argument): @@ -43,7 +44,10 @@ class DateArgument(Argument): def match(self, val: str, evt: MessageEvent = None, instance: 'ReminderBot' = None ) -> Tuple[str, Optional[datetime]]: - tz = pytz.UTC + try: + tz = pytz.timezone(instance.config["timezone"]) + except (pytz.UnknownTimeZoneError, StopIteration, IndexError): + tz = pytz.UTC use_locales = [locales["en_iso"]] if instance: tz = instance.db.get_timezone(evt.sender)