code: def _datetime_to_epoch(self, dt):
          
          if dt:
              td = (dt - datetime.datetime.fromtimestamp(0, tzutc()))
              # don't use total_seconds(), that's only available in 2.7
              total_secs = int((td.microseconds +
                                (td.seconds + td.days * 24 * 3600) *
                                10**6) / 10**6)
              return total_secs
          else:
              return 0
docs: Convert the datetime to unix epoch (properly).