1
0
Fork 0
mirror of synced 2024-06-27 02:20:36 +12:00

better timestamp handling

This commit is contained in:
Nick Sweeting 2020-04-22 21:15:15 -04:00
parent afacc5c5da
commit 9fc431102b

View file

@ -2,7 +2,7 @@ __package__ = 'archivebox.index'
import os
from datetime import datetime
from datetime import datetime, timedelta
from typing import List, Dict, Any, Optional, Union
@ -268,7 +268,16 @@ class Link:
@property
def bookmarked_date(self) -> Optional[str]:
from ..util import ts_to_date
return ts_to_date(self.timestamp) if self.timestamp else None
max_ts = (datetime.now() + timedelta(days=30)).timestamp()
if self.timestamp and self.timestamp.replace('.', '').isdigit():
if 0 < float(self.timestamp) < max_ts:
return ts_to_date(datetime.fromtimestamp(float(self.timestamp)))
else:
return str(self.timestamp)
return None
@property
def updated_date(self) -> Optional[str]: