Files
rengine/shared/utils/datetime.py
T
Yogesh Ojha 1945242c1b feat: implement scan scheduling functionality
- Added new types and interfaces for scan scheduling in the frontend.
- Created a new Svelte page for managing scheduled scans, including listing, creating, editing, and deleting schedules.
- Implemented backend models and services for scan schedules, including handling different schedule types (one-off, interval, daily, cron).
- Introduced a Celery task to manage the execution of scheduled scans based on their defined timing.
- Enhanced notification system to include alerts for newly discovered subdomains during scans.
- Added utility functions for handling time zones and scheduling logic.
2026-06-24 08:10:21 +05:30

23 lines
502 B
Python

from datetime import UTC, datetime
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
def is_valid_timezone(tz: str) -> bool:
try:
ZoneInfo(tz)
except (ZoneInfoNotFoundError, ValueError):
return False
return True
def normalize_datetime(dt: datetime | None) -> datetime | None:
if dt is None:
return None
if dt.tzinfo is None:
return dt.replace(tzinfo=UTC)
return dt.astimezone(UTC)
def utc_now() -> datetime:
return datetime.now(UTC)