code: def _get_timestamp_ms(when):
    
    if when is None:
      return None
    ms_since_epoch = float(time.mktime(when.utctimetuple()) * 1000.0)
    ms_since_epoch += when.microsecond / 1000.0
    return int(ms_since_epoch)
docs: Converts a datetime.datetime to integer milliseconds since the epoch.
  
    Requires special handling to preserve microseconds.
  
    Args:
      when: A datetime.datetime instance.
  
    Returns:
      Integer time since the epoch in milliseconds. If the supplied 'when' is
      None, the return value will be None.