Skip to content

Commit

Permalink
check default_time before parsing
Browse files Browse the repository at this point in the history
fix Guts#290

Signed-off-by: Zhiyuan Chen <[email protected]>
  • Loading branch information
ZhiyuanChen authored Jun 11, 2024
1 parent 7e51e12 commit 7b648f4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mkdocs_rss_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# standard library
import json
from copy import deepcopy
from datetime import datetime
from datetime import datetime, time
from email.utils import formatdate
from pathlib import Path
from re import compile as re_compile
Expand Down Expand Up @@ -160,9 +160,10 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig:

# check if default time complies with expected format
try:
self.config.date_from_meta.default_time = datetime.strptime(
self.config.date_from_meta.default_time, "%H:%M"
)
if not isinstance(self.config.date_from_meta.default_time, (datetime, time)):
self.config.date_from_meta.default_time = datetime.strptime(
self.config.date_from_meta.default_time, "%H:%M"
)
except ValueError as err:
raise PluginError(
"Config error: `date_from_meta.default_time` value "
Expand Down

0 comments on commit 7b648f4

Please sign in to comment.