[dt] replace 'datetime' imports

This commit is contained in:
Mike Fährmann
2025-10-16 10:59:03 +02:00
parent 21350c5084
commit 69f7cfdd0c
10 changed files with 44 additions and 53 deletions

View File

@@ -13,7 +13,6 @@ import sys
import time
import string
import _string
import datetime
import operator
from . import text, util, dt
@@ -484,13 +483,13 @@ def _parse_offset(format_spec, default):
if not offset or offset == "local":
def off(dt_utc):
local = time.localtime(dt.to_ts(dt_utc))
return fmt(dt_utc + datetime.timedelta(0, local.tm_gmtoff))
return fmt(dt_utc + dt.timedelta(0, local.tm_gmtoff))
else:
hours, _, minutes = offset.partition(":")
offset = 3600 * int(hours)
if minutes:
offset += 60 * (int(minutes) if offset > 0 else -int(minutes))
offset = datetime.timedelta(0, offset)
offset = dt.timedelta(0, offset)
def off(obj):
return fmt(obj + offset)
@@ -557,7 +556,7 @@ _FORMATTERS = {
_GLOBALS = {
"_env": lambda: os.environ,
"_lit": lambda: _literal,
"_now": datetime.datetime.now,
"_now": dt.datetime.now,
"_nul": lambda: util.NONE,
}
_CONVERSIONS = {