from datetime import datetime
import time


def datetime2timestamp(datetime_=None):
    """
    Convert local datetime to unix timestamp
    """
    if datetime_ is None:
        datetime_ = datetime.now()
    if not isinstance(datetime_, datetime):
        return 0
    return datetime_ and int(time.mktime(datetime_.timetuple()))