code: def to_timestamp(dt):
      
      if isinstance(dt, int):
          return dt
      return int(total_seconds(dt.replace(tzinfo=None) -
                 datetime.datetime(1970, 1, 1)))
docs: Convert a datetime object to a unix timestamp.
  
      Note that unlike a typical unix timestamp, this is seconds since 1970
      *local time*, not UTC.
  
      If the passed in object is already a timestamp, then that value is
      simply returned unmodified.