From 338fd54e6b772bfd8be7bbbf64b580194f2a5fd2 Mon Sep 17 00:00:00 2001 From: iou1name Date: Wed, 16 Feb 2022 17:23:33 -0500 Subject: [PATCH] fix leapday issue in relative timestamp function --- modules/bq.py | 1 + tools.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/modules/bq.py b/modules/bq.py index 20408ef..c10dc0b 100755 --- a/modules/bq.py +++ b/modules/bq.py @@ -12,6 +12,7 @@ from module import commands def BQstatus(bot, trigger): """ Displays the current status of BQ. + https://twitter.com/Quidam_Asinus/status/1067130989422489600 """ status = "\x0304DEAD" deathdate = datetime(2017, 2, 16, 0, 19, 0) diff --git a/tools.py b/tools.py index 8838c86..f2c5037 100755 --- a/tools.py +++ b/tools.py @@ -4,6 +4,7 @@ Some helper functions and other tools. """ import re import argparse +import calendar import threading from collections import defaultdict from datetime import datetime @@ -231,6 +232,7 @@ def relative_time(time_1, time_2): units['year'] = diff.days // 365 if diff.days >= 0: units['day'] = diff.days - units.get('year', 0)*365 + units['day'] -= calendar.leapdays(time_2.year, time_1.year) if not any(units.values()): if diff.seconds // 3600: