From 4dde98dad1b8b4e0eeb070ea4ed7a6fbf68cf48f Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 14 Feb 2020 21:23:07 +0000 Subject: [PATCH] Calculate timezone offset for daylight savings time --- bootstrap.py | 2 ++ houdini/handlers/play/navigation.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bootstrap.py b/bootstrap.py index b79859c..56542e6 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -25,6 +25,8 @@ if __name__ == '__main__': nargs='*', help='Plugins to load') parser.add_argument('-l', '--lang', action='store', default='en', help='Houdini language', choices=['en', 'fr', 'pt', 'es', 'de', 'ru']) + parser.add_argument('-tz', '--timezone', action='store', default='America/Vancouver', + help='Server timezone') login_group = parser.add_argument_group('login') login_group.add_argument('--login-failure-limit', action='store', default=5, help='Limit before flood limit', diff --git a/houdini/handlers/play/navigation.py b/houdini/handlers/play/navigation.py index 35b9f71..116e1e6 100644 --- a/houdini/handlers/play/navigation.py +++ b/houdini/handlers/play/navigation.py @@ -29,7 +29,10 @@ async def handle_join_server(p, penguin_id: int, login_key: str): current_time = int(time.time()) penguin_standard_time = current_time * 1000 - server_time_offset = 7 + + pst = pytz.timezone(p.server.config.timezone) + dt = datetime.fromtimestamp(current_time, pst) + server_time_offset = abs(int(dt.strftime('%z')) // 100) if p.timer_active: minutes_until_timer_end = datetime.combine(datetime.today(), p.timer_end) - datetime.now()