mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -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)
|
||||
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue