Convert the datetime to unix epoch (properly).

def _datetime_to_epoch(self, dt):
        """Convert the datetime to unix epoch (properly)."""
        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