Skip to content

Commit eee4934

Browse files
authored
Fixed blog plugin crashing on missing timezone (regression) (#7730)
* Default timezone to UTC for blog plugin created date Fix for #7725 * Fix variable name * Run build
1 parent 0947f73 commit eee4934

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

material/plugins/blog/structure/options.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ def pre_validation(self, config: Config, key_name: str):
6666
# Handle datetime - since datetime is a subclass of date, we need
6767
# to check it first, or we lose the time - see https://t.ly/-KG9N
6868
if isinstance(value, datetime):
69-
continue
69+
# Set timezone to UTC if not set
70+
if value.tzinfo is None:
71+
config[key_name][key] = value.replace(tzinfo=timezone.utc)
72+
continue;
73+
7074

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

src/plugins/blog/structure/options.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ def pre_validation(self, config: Config, key_name: str):
6666
# Handle datetime - since datetime is a subclass of date, we need
6767
# to check it first, or we lose the time - see https://t.ly/-KG9N
6868
if isinstance(value, datetime):
69-
continue
69+
# Set timezone to UTC if not set
70+
if value.tzinfo is None:
71+
config[key_name][key] = value.replace(tzinfo=timezone.utc)
72+
continue;
73+
7074

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

0 commit comments

Comments
 (0)