Files
bakery-ia/shared/dt_utils/__init__.py

113 lines
2.5 KiB
Python
Executable File

"""
DateTime and Timezone Utilities
Modern, clean datetime and timezone handling for the bakery system.
Uses Python's built-in zoneinfo (Python 3.9+) for timezone operations.
Public API:
Core operations (from core.py):
- utc_now, now_in_timezone
- to_utc, to_timezone
- ensure_aware, ensure_naive
- parse_iso, format_iso, format_custom
- is_aware, validate_timezone
Timezone operations (from timezone.py):
- get_timezone_info, get_utc_offset_hours
- list_supported_timezones
- get_current_date_in_tz, get_current_datetime_in_tz
- combine_date_time_in_tz
- convert_to_utc, convert_from_utc
Business logic (from business.py):
- is_business_hours, next_business_day
- get_business_day_range
- get_tenant_now, is_tenant_business_hours
Constants (from constants.py):
- DEFAULT_TIMEZONE
- SUPPORTED_TIMEZONES
- BUSINESS_HOURS_DEFAULT
"""
from .core import (
utc_now,
now_in_timezone,
to_utc,
to_timezone,
ensure_aware,
ensure_naive,
parse_iso,
format_iso,
format_custom,
is_aware,
validate_timezone,
)
from .timezone import (
get_timezone_info,
get_utc_offset_hours,
list_supported_timezones,
get_current_date_in_tz,
get_current_datetime_in_tz,
combine_date_time_in_tz,
convert_to_utc,
convert_from_utc,
)
from .business import (
is_business_hours,
next_business_day,
get_business_day_range,
get_tenant_now,
is_tenant_business_hours,
)
from .constants import (
DEFAULT_TIMEZONE,
SUPPORTED_TIMEZONES,
BUSINESS_HOURS_DEFAULT,
ISO_FORMAT,
DATE_FORMAT,
TIME_FORMAT,
DATETIME_FORMAT,
)
__all__ = [
# Core operations
"utc_now",
"now_in_timezone",
"to_utc",
"to_timezone",
"ensure_aware",
"ensure_naive",
"parse_iso",
"format_iso",
"format_custom",
"is_aware",
"validate_timezone",
# Timezone operations
"get_timezone_info",
"get_utc_offset_hours",
"list_supported_timezones",
"get_current_date_in_tz",
"get_current_datetime_in_tz",
"combine_date_time_in_tz",
"convert_to_utc",
"convert_from_utc",
# Business logic
"is_business_hours",
"next_business_day",
"get_business_day_range",
"get_tenant_now",
"is_tenant_business_hours",
# Constants
"DEFAULT_TIMEZONE",
"SUPPORTED_TIMEZONES",
"BUSINESS_HOURS_DEFAULT",
"ISO_FORMAT",
"DATE_FORMAT",
"TIME_FORMAT",
"DATETIME_FORMAT",
]