1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-27 17:00:54 +01:00

Fixed blog plugin crashing on missing timezone (regression) (#7730)

* Default timezone to UTC for blog plugin created date

Fix for https://github.com/squidfunk/mkdocs-material/issues/7725

* Fix variable name

* Run build
This commit is contained in:
perpil 2024-11-20 09:22:48 -08:00 committed by GitHub
parent 0947f73db3
commit eee4934efd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -66,7 +66,11 @@ class PostDate(BaseConfigOption[DateDict]):
# 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

View File

@ -66,7 +66,11 @@ class PostDate(BaseConfigOption[DateDict]):
# 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