def _datetime_to_millis(dtm):
    """Convert datetime to milliseconds since epoch UTC."""
    if dtm.utcoffset() is not None:
        dtm = dtm - dtm.utcoffset()
    return int(calendar.timegm(dtm.timetuple()) * 1000 +
               dtm.microsecond // 1000)
Convert datetime to milliseconds since epoch UTC.
stackoverflow/venv/lib/python3.6/site-packages/bson/__init__.py