mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-20 18:05:19 -04:00
better timestamp handling
This commit is contained in:
parent
afacc5c5da
commit
9fc431102b
1 changed files with 11 additions and 2 deletions
|
@ -2,7 +2,7 @@ __package__ = 'archivebox.index'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from typing import List, Dict, Any, Optional, Union
|
from typing import List, Dict, Any, Optional, Union
|
||||||
|
|
||||||
|
@ -268,7 +268,16 @@ class Link:
|
||||||
@property
|
@property
|
||||||
def bookmarked_date(self) -> Optional[str]:
|
def bookmarked_date(self) -> Optional[str]:
|
||||||
from ..util import ts_to_date
|
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
|
@property
|
||||||
def updated_date(self) -> Optional[str]:
|
def updated_date(self) -> Optional[str]:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue