diff --git a/mkdocs_rss_plugin/timezoner_py39.py b/mkdocs_rss_plugin/timezoner.py similarity index 100% rename from mkdocs_rss_plugin/timezoner_py39.py rename to mkdocs_rss_plugin/timezoner.py diff --git a/mkdocs_rss_plugin/timezoner_pre39.py b/mkdocs_rss_plugin/timezoner_pre39.py deleted file mode 100644 index 73ae7e5..0000000 --- a/mkdocs_rss_plugin/timezoner_pre39.py +++ /dev/null @@ -1,56 +0,0 @@ -#! python3 # noqa: E265 - - -""" - Manage timezones for pages date(time)s using pytz module. - Meant to be dropped when Python 3.8 reaches EOL. -""" - -# ############################################################################ -# ########## Libraries ############# -# ################################## - -# standard library -from datetime import datetime - -# 3rd party -import pytz -from mkdocs.plugins import get_plugin_logger - -# package -from mkdocs_rss_plugin.constants import MKDOCS_LOGGER_NAME - -# ############################################################################ -# ########## Globals ############# -# ################################ - - -logger = get_plugin_logger(MKDOCS_LOGGER_NAME) - - -# ############################################################################ -# ########## Functions ########### -# ################################ - - -def set_datetime_zoneinfo( - input_datetime: datetime, config_timezone: str = "UTC" -) -> datetime: - """Apply timezone to a naive datetime. - - :param input_datetime: offset-naive datetime - :type input_datetime: datetime - :param config_timezone: name of timezone as registered in IANA database, - defaults to "UTC". Example : Europe/Paris. - :type config_timezone: str, optional - - :return: offset-aware datetime - :rtype: datetime - """ - if input_datetime.tzinfo: - return input_datetime - elif not config_timezone: - return input_datetime.replace(tzinfo=pytz.utc) - else: - config_tz = pytz.timezone(config_timezone) - return config_tz.localize(input_datetime) diff --git a/mkdocs_rss_plugin/util.py b/mkdocs_rss_plugin/util.py index 6e56ade..e966fe0 100644 --- a/mkdocs_rss_plugin/util.py +++ b/mkdocs_rss_plugin/util.py @@ -31,9 +31,7 @@ from mkdocs_rss_plugin.integrations.theme_material_social_plugin import ( IntegrationMaterialSocialCards, ) - -# conditional imports -from mkdocs_rss_plugin.timezoner_py39 import set_datetime_zoneinfo +from mkdocs_rss_plugin.timezoner import set_datetime_zoneinfo # ############################################################################ # ########## Globals ############# diff --git a/requirements/base.txt b/requirements/base.txt index 1fa26c6..fc74df5 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -4,5 +4,4 @@ GitPython>=3.1,<3.2 mkdocs>=1.5,<2 -pytz==2022.* ; python_version < "3.9" tzdata==2024.* ; python_version >= "3.9" and sys_platform == "win32"