Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set timezone to UTC when draft_if_future_date: true Fixes #7748 #7749

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(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(timezone.utc)

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