mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
guard against null date
This commit is contained in:
parent
5ededc0727
commit
14ddb92922
1 changed files with 4 additions and 0 deletions
|
@ -458,11 +458,15 @@ def awaken_dormant_instance(instance):
|
||||||
|
|
||||||
epoch = datetime(1970, 1, 1)
|
epoch = datetime(1970, 1, 1)
|
||||||
|
|
||||||
|
|
||||||
def epoch_seconds(date):
|
def epoch_seconds(date):
|
||||||
td = date - epoch
|
td = date - epoch
|
||||||
return td.days * 86400 + td.seconds + (float(td.microseconds) / 1000000)
|
return td.days * 86400 + td.seconds + (float(td.microseconds) / 1000000)
|
||||||
|
|
||||||
|
|
||||||
def post_ranking(score, date: datetime):
|
def post_ranking(score, date: datetime):
|
||||||
|
if date is None:
|
||||||
|
date = datetime.utcnow()
|
||||||
order = math.log(max(abs(score), 1), 10)
|
order = math.log(max(abs(score), 1), 10)
|
||||||
sign = 1 if score > 0 else -1 if score < 0 else 0
|
sign = 1 if score > 0 else -1 if score < 0 else 0
|
||||||
seconds = epoch_seconds(date) - 1685766018
|
seconds = epoch_seconds(date) - 1685766018
|
||||||
|
|
Loading…
Add table
Reference in a new issue