Skip to content

Commit

Permalink
Fixe time being dropped from blog post dates
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Dec 7, 2023
1 parent 63de1a0 commit 5b70a0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions material/plugins/blog/structure/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def pre_validation(self, config: Config, key_name: str):

# Convert all date values to datetime
for key, value in config[key_name].items():

# Handle datetime - since datetime is a subclass of date, we need
# to check it first, or we'll loose time - see https://t.ly/-KG9N
if isinstance(value, datetime):
continue

# Handle date - we set 00:00:00 as the default time, if the author
# only supplied a date, and convert it to datetime
if isinstance(value, date):
config[key_name][key] = datetime.combine(value, time())

Expand Down
8 changes: 8 additions & 0 deletions src/plugins/blog/structure/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def pre_validation(self, config: Config, key_name: str):

# Convert all date values to datetime
for key, value in config[key_name].items():

# Handle datetime - since datetime is a subclass of date, we need
# to check it first, or we'll loose time - see https://t.ly/-KG9N
if isinstance(value, datetime):
continue

# Handle date - we set 00:00:00 as the default time, if the author
# only supplied a date, and convert it to datetime
if isinstance(value, date):
config[key_name][key] = datetime.combine(value, time())

Expand Down

0 comments on commit 5b70a0c

Please sign in to comment.