1
0
mirror of https://github.com/sui-feng-cb/AzurLaneAutoScript1.git synced 2026-07-13 10:58:02 +08:00

Feat: add module smart_mgmt

This commit is contained in:
positnuec
2026-07-10 07:25:18 +08:00
parent f92ee9907d
commit 9cc7aa804b
16 changed files with 727 additions and 6 deletions

View File

@@ -0,0 +1,34 @@
from __future__ import annotations
import re
from datetime import datetime
from typing import Optional
from module.logger import logger
DOWNTIME_FORMAT_RE = re.compile(
r'(\d{4})-(\d{1,2})-(\d{1,2}) '
r'(\d{1,2}):(\d{2})~(\d{1,2}):(\d{2})',
)
def parse_downtime(downtime: str) -> Optional[datetime]:
"""
Parse downtime window string into end datetime.
Args:
downtime (str): Window string in format 'YYYY-MM-DD HH:MM~HH:MM'.
Returns:
Optional[datetime]: End datetime parsed from the window,
or None if no pattern matched.
"""
match = DOWNTIME_FORMAT_RE.search(downtime)
if not match:
logger.warning(f'Failed to parse downtime window: {downtime}')
return None
year, month, day = int(match.group(1)), int(match.group(2)), int(match.group(3))
end_hour, end_minute = int(match.group(6)), int(match.group(7))
end_dt = datetime(year, month, day, end_hour, end_minute)
logger.info(f'Parsed downtime window: end={end_dt:%Y-%m-%d %H:%M}')
return end_dt