From 6288b26b902b2492df610db7c0a69f7c66e94ab1 Mon Sep 17 00:00:00 2001 From: perpil <97474956+perpil@users.noreply.github.com> Date: Mon, 25 Nov 2024 09:13:00 -0800 Subject: [PATCH] Fixed timezone when draft_if_future_date: true (#7749) * Set timezone to UTC when draft_if_future_date: true Fixes #7748 * Use more compact form of setting timezone --- material/plugins/blog/plugin.py | 4 ++-- src/plugins/blog/plugin.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index da64432dec9..6dbd4a19e9d 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -26,7 +26,7 @@ import yaml from babel.dates import format_date, format_datetime -from datetime import datetime +from datetime import datetime, timezone from jinja2 import pass_context from jinja2.runtime import Context from mkdocs.config.defaults import MkDocsConfig @@ -370,7 +370,7 @@ def _is_excluded(self, post: Post): # and must be explicitly enabled by the author. if not isinstance(post.config.draft, bool): if self.config.draft_if_future_date: - return post.config.date.created > datetime.now() + return post.config.date.created > datetime.now(timezone.utc) # Post might be a draft return bool(post.config.draft) diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index da64432dec9..6dbd4a19e9d 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -26,7 +26,7 @@ import yaml from babel.dates import format_date, format_datetime -from datetime import datetime +from datetime import datetime, timezone from jinja2 import pass_context from jinja2.runtime import Context from mkdocs.config.defaults import MkDocsConfig @@ -370,7 +370,7 @@ def _is_excluded(self, post: Post): # and must be explicitly enabled by the author. if not isinstance(post.config.draft, bool): if self.config.draft_if_future_date: - return post.config.date.created > datetime.now() + return post.config.date.created > datetime.now(timezone.utc) # Post might be a draft return bool(post.config.draft)