code: def _to_micros(dur):
      
      if hasattr(dur, 'total_seconds'):
          return int(dur.total_seconds() * 10e5)
      # Python 2.6
      return dur.microseconds + (dur.seconds + dur.days * 24 * 3600) * 1000000
docs: Convert duration 'dur' to microseconds.