fix leapday issue in relative timestamp function

This commit is contained in:
iou1name 2022-02-16 17:23:33 -05:00
parent bcef6330cc
commit 338fd54e6b
2 changed files with 3 additions and 0 deletions

View File

@ -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)

View File

@ -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: