import calendar


def datetime_to_int(ts):
    """
    accepts: datetime object (tz aware)
    returns: integer (unix time - seconds)
    """
    if (ts.tzinfo == None): raise Exception("timestamps must not be naive")
    return int(calendar.timegm(ts.utctimetuple()))