mirror of
https://codeberg.org/Reuh/feather.git
synced 2025-10-27 10:09:32 +00:00
fix: timestamps are floats
This commit is contained in:
parent
22b2ea89d5
commit
aad1197d5c
1 changed files with 5 additions and 5 deletions
|
|
@ -38,7 +38,7 @@ def sanitize_filename(
|
||||||
return filename[:cutoff] + "…" + insert_before_suffix + suffix
|
return filename[:cutoff] + "…" + insert_before_suffix + suffix
|
||||||
|
|
||||||
|
|
||||||
def format_datetime(config: Config, timestamp: int) -> str:
|
def format_datetime(config: Config, timestamp: float) -> str:
|
||||||
"""Format a timestamp according to the configuration."""
|
"""Format a timestamp according to the configuration."""
|
||||||
if timestamp < 0:
|
if timestamp < 0:
|
||||||
date = datetime(1970, 1, 1, tzinfo=config.timezone) + timedelta(
|
date = datetime(1970, 1, 1, tzinfo=config.timezone) + timedelta(
|
||||||
|
|
@ -103,8 +103,8 @@ class Article(ABC):
|
||||||
# with default value
|
# with default value
|
||||||
unread: bool = True # if the article is unread
|
unread: bool = True # if the article is unread
|
||||||
title: str = "" # article title
|
title: str = "" # article title
|
||||||
published: int = 0 # article publication time (timestamp)
|
published: float = 0.0 # article publication time (timestamp)
|
||||||
updated: int = 0 # article update time (timestamp)
|
updated: float = 0.0 # article update time (timestamp)
|
||||||
author: str = "" # article author
|
author: str = "" # article author
|
||||||
summary: str = "" # article summary (HTML)
|
summary: str = "" # article summary (HTML)
|
||||||
content: str = "" # article content (HTML)
|
content: str = "" # article content (HTML)
|
||||||
|
|
@ -116,7 +116,7 @@ class Article(ABC):
|
||||||
comments_url: str = "" # article comments URL
|
comments_url: str = "" # article comments URL
|
||||||
language: str = "" # article language
|
language: str = "" # article language
|
||||||
image_url: str = "" # article main image
|
image_url: str = "" # article main image
|
||||||
last_write: int = 0 # last time this article file was written (timestamp)
|
last_write: float = 0.0 # last time this article file was written (timestamp)
|
||||||
|
|
||||||
def _hash_id(self):
|
def _hash_id(self):
|
||||||
return sha256(str(self.id).encode("utf-8")).hexdigest()
|
return sha256(str(self.id).encode("utf-8")).hexdigest()
|
||||||
|
|
@ -231,7 +231,7 @@ class Article(ABC):
|
||||||
html_path, config.article_template.render(self._get_template_dict())
|
html_path, config.article_template.render(self._get_template_dict())
|
||||||
)
|
)
|
||||||
# set accessed date to update time, modified to publication time
|
# set accessed date to update time, modified to publication time
|
||||||
os.utime(html_path, (max(self.published, self.updated), self.published))
|
os.utime(html_path, (max(int(self.published), int(self.updated)), int(self.published)))
|
||||||
|
|
||||||
def _delete_html(self, missing_ok=False):
|
def _delete_html(self, missing_ok=False):
|
||||||
"""Delete the HTML file associated with this article."""
|
"""Delete the HTML file associated with this article."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue