Skip to content

Commit

Permalink
Fixed blog plugin crashing on missing timezone (regression) (#7730)
Browse files Browse the repository at this point in the history
* Default timezone to UTC for blog plugin created date

Fix for #7725

* Fix variable name

* Run build
  • Loading branch information
perpil authored Nov 20, 2024
1 parent 0947f73 commit eee4934
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion material/plugins/blog/structure/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def pre_validation(self, config: Config, key_name: str):
# Handle datetime - since datetime is a subclass of date, we need
# to check it first, or we lose the time - see https://t.ly/-KG9N
if isinstance(value, datetime):
continue
# Set timezone to UTC if not set
if value.tzinfo is None:
config[key_name][key] = value.replace(tzinfo=timezone.utc)
continue;


# Handle date - we set 00:00:00 as the default time, if the author
# only supplied a date, and convert it to datetime in UTC
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/blog/structure/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def pre_validation(self, config: Config, key_name: str):
# Handle datetime - since datetime is a subclass of date, we need
# to check it first, or we lose the time - see https://t.ly/-KG9N
if isinstance(value, datetime):
continue
# Set timezone to UTC if not set
if value.tzinfo is None:
config[key_name][key] = value.replace(tzinfo=timezone.utc)
continue;


# Handle date - we set 00:00:00 as the default time, if the author
# only supplied a date, and convert it to datetime in UTC
Expand Down

0 comments on commit eee4934

Please sign in to comment.