guard against null date

This commit is contained in:
rimu 2024-01-05 08:11:35 +13:00
parent 5ededc0727
commit 14ddb92922

View file

@ -458,11 +458,15 @@ def awaken_dormant_instance(instance):
epoch = datetime(1970, 1, 1)
def epoch_seconds(date):
td = date - epoch
return td.days * 86400 + td.seconds + (float(td.microseconds) / 1000000)
def post_ranking(score, date: datetime):
if date is None:
date = datetime.utcnow()
order = math.log(max(abs(score), 1), 10)
sign = 1 if score > 0 else -1 if score < 0 else 0
seconds = epoch_seconds(date) - 1685766018