mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2025-01-31 03:43: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:
parent
b88d1f0eb9
commit
6288b26b90
@ -26,7 +26,7 @@ import posixpath
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from babel.dates import format_date, format_datetime
|
from babel.dates import format_date, format_datetime
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
from jinja2 import pass_context
|
from jinja2 import pass_context
|
||||||
from jinja2.runtime import Context
|
from jinja2.runtime import Context
|
||||||
from mkdocs.config.defaults import MkDocsConfig
|
from mkdocs.config.defaults import MkDocsConfig
|
||||||
@ -370,7 +370,7 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
# and must be explicitly enabled by the author.
|
# and must be explicitly enabled by the author.
|
||||||
if not isinstance(post.config.draft, bool):
|
if not isinstance(post.config.draft, bool):
|
||||||
if self.config.draft_if_future_date:
|
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
|
# Post might be a draft
|
||||||
return bool(post.config.draft)
|
return bool(post.config.draft)
|
||||||
|
@ -26,7 +26,7 @@ import posixpath
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from babel.dates import format_date, format_datetime
|
from babel.dates import format_date, format_datetime
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
from jinja2 import pass_context
|
from jinja2 import pass_context
|
||||||
from jinja2.runtime import Context
|
from jinja2.runtime import Context
|
||||||
from mkdocs.config.defaults import MkDocsConfig
|
from mkdocs.config.defaults import MkDocsConfig
|
||||||
@ -370,7 +370,7 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
# and must be explicitly enabled by the author.
|
# and must be explicitly enabled by the author.
|
||||||
if not isinstance(post.config.draft, bool):
|
if not isinstance(post.config.draft, bool):
|
||||||
if self.config.draft_if_future_date:
|
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
|
# Post might be a draft
|
||||||
return bool(post.config.draft)
|
return bool(post.config.draft)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user