Skip to content
Snippets Groups Projects
Unverified Commit 5fc92aa6 authored by Dominik George's avatar Dominik George
Browse files

Make default timezone configurable. Closes #17

parent 6ebfc8ca
No related branches found
No related tags found
No related merge requests found
...@@ -3,3 +3,6 @@ ...@@ -3,3 +3,6 @@
base_command: base_command:
- remind - remind
- reminder - reminder
# Default timezone for users who did not set one
timezone: 'UTC'
...@@ -35,6 +35,7 @@ if TYPE_CHECKING: ...@@ -35,6 +35,7 @@ if TYPE_CHECKING:
class Config(BaseProxyConfig): class Config(BaseProxyConfig):
def do_update(self, helper: ConfigUpdateHelper) -> None: def do_update(self, helper: ConfigUpdateHelper) -> None:
helper.copy("base_command") helper.copy("base_command")
helper.copy("timezone")
class DateArgument(Argument): class DateArgument(Argument):
...@@ -43,7 +44,10 @@ class DateArgument(Argument): ...@@ -43,7 +44,10 @@ class DateArgument(Argument):
def match(self, val: str, evt: MessageEvent = None, instance: 'ReminderBot' = None def match(self, val: str, evt: MessageEvent = None, instance: 'ReminderBot' = None
) -> Tuple[str, Optional[datetime]]: ) -> 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"]] use_locales = [locales["en_iso"]]
if instance: if instance:
tz = instance.db.get_timezone(evt.sender) tz = instance.db.get_timezone(evt.sender)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment