Skip to content

Commit

Permalink
Fixed timezone when draft_if_future_date: true (#7749)
Browse files Browse the repository at this point in the history
* Set timezone to UTC when draft_if_future_date: true Fixes #7748

* Use more compact form of setting timezone
  • Loading branch information
perpil authored Nov 25, 2024
1 parent b88d1f0 commit 6288b26
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(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

0 comments on commit 6288b26

Please sign in to comment.