1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2025-01-18 08:54:46 +01:00

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
This commit is contained in:
perpil 2024-11-25 09:13:00 -08:00 committed by GitHub
parent b88d1f0eb9
commit 6288b26b90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -26,7 +26,7 @@ import posixpath
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 @@ class BlogPlugin(BasePlugin[BlogConfig]):
# 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)

View File

@ -26,7 +26,7 @@ import posixpath
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 @@ class BlogPlugin(BasePlugin[BlogConfig]):
# 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)