from datetime import datetime
import time


def get_end_date_of_schedule(schedule):
    """Return the end date of the provided schedule in ISO 8601 format"""
    currenttime = datetime.today()
    endtime = datetime(
        currenttime.year, currenttime.month, currenttime.day, schedule['end-hour'], schedule['end-minute'])
    # manually create ISO8601 string because of tz issues with Python2
    ts = time.time()
    utc_offset = ((datetime.fromtimestamp(
        ts) - datetime.utcfromtimestamp(ts)).total_seconds()) / 3600
    offset = str(int(abs(utc_offset * 100))).zfill(4)
    sign = "+" if utc_offset >= 0 else "-"

    return endtime.strftime("%Y-%m-%dT%H:%M:%S{sign}{offset}".format(sign=sign, offset=offset))