from datetime import datetime


def to_time_string(value):
    """
    gets the time string representation of input datetime with utc offset.

    for example: `23:40:15`

    :param datetime | time value: input object to be converted.

    :rtype: str
    """

    time = value
    if isinstance(value, datetime):
        time = value.timetz()

    return time.isoformat(timespec='seconds')