import calendar


def to_unix_timestamp(timestamp):
    """
    Convert datetime object to unix timestamp. Input is local time, result is an
    UTC timestamp.
    """

    if timestamp is not None:
        return calendar.timegm(timestamp.utctimetuple())