Returns the time offset from UTC accounting for DST

    Keyword Arguments:
        time_struct {time.struct_time} -- the struct time for which to
                                          return the UTC offset.
                                          If None, use current local time.

def utc_offset(time_struct=None):
    """
    Returns the time offset from UTC accounting for DST

    Keyword Arguments:
        time_struct {time.struct_time} -- the struct time for which to
                                          return the UTC offset.
                                          If None, use current local time.
    """
    if time_struct:
        ts = time_struct
    else:
        ts = time.localtime()

    if ts[-1]:
        offset = time.altzone
    else:
        offset = time.timezone
    return offset