zeusops / operationbot

A bot for handling events on the Zeusops discord server
GNU General Public License v3.0
7 stars 4 forks source link

Event's "Local time" field is not timezone-aware #97

Closed Gehock closed 1 year ago

Gehock commented 2 years ago

Currently Event just uses the server's timezone.

A quick fix, should be made configurable via config.py:

    def createEmbed(self) -> Embed:
        date = self.date.strftime(f"%a %Y-%m-%d - %H:%M {cfg.TIME_ZONE}")
        title = f"{self.title} ({date})"
        local_time = f"<t:{int(self.date.replace(tzinfo=datetime.timezone(offset=datetime.timedelta(hours=0))).timestamp())}>"
        relative_time = f"<t:{int(self.date.replace(tzinfo=datetime.timezone(offset=datetime.timedelta(hours=0))).timestamp())}:R>"
        server_port = (f"\nServer port: **{self.port}**"
                       if self.port != cfg.PORT_DEFAULT else "")
        event_description = (f"\n\n{self.description}"
                             if self.description else "")
Gehock commented 1 year ago

Fixed in f3c821bd1127ab15349bb925cb7d17e5f60fbcf1. Dates within the events are still timezone-naive, but local time is converted into UTC correctly.