from datetime import datetime, time, timedelta


def convert_time_to_safe_string(t: time) -> str:
    """
    Converts time to a string that can be used as a file name.
    :param t: time object
    :return: safe string
    """
    return f"{t.hour}_{t.minute:02d}_{t.second:02d}"


def format_timedelta(td: timedelta) -> str:
    """
    Unified formatting of timedelta.
    :param td: timedelta object
    :return: formatted string
    """
    seconds = td.total_seconds()
    hours = int(seconds // 3600)
    minutes = int((seconds % 3600) // 60)
    seconds = int(seconds % 60)
    return f"{hours}:{minutes:02d}:{seconds:02d}"


def format_time(t: time) -> str:
    """
    Unified formatting of time.
    :param t: time object
    :return: formatted string
    """
    return f"{t.hour}:{t.minute:02d}:{t.second:02d}"


def format_datetime(dt: datetime) -> str:
    """
    Unified formatting of datetime.
    :param dt: datetime object
    :return: formatted string
    """
    return dt.strftime("%d.%m.%Y %H:%M:%S")


def create_safe_string(original: str) -> str:
    """
    Creates a safe string from the original string.
    :param original: original string
    :return: safe string
    """
    allowed_symbols = ("_", "-")
    return "".join(c for c in original if c.isalnum() or c in allowed_symbols).rstrip()
