Skip to content

Commit

Permalink
Set timezone to UTC when draft_if_future_date: true Fixes #7748
Browse files Browse the repository at this point in the history
  • Loading branch information
perpil committed Nov 25, 2024
1 parent b88d1f0 commit 90578fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions material/plugins/blog/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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().replace(tzinfo=timezone.utc)

# Post might be a draft
return bool(post.config.draft)
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/blog/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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().replace(tzinfo=timezone.utc)

# Post might be a draft
return bool(post.config.draft)
Expand Down

0 comments on commit 90578fe

Please sign in to comment.