def WmiTimeToEpoch(cimdatetime_str):
 re_match = TIME_WMI_RE.match(cimdatetime_str)
 try:
  t_dict = re_match.groupdict()
  flt_time = time.strptime(t_dict['date'], '%Y%m%d%H%M%S')
  epoch_time = (int(calendar.timegm(flt_time)) * 1000000)
  epoch_time += int(t_dict['subsecond'])
  return epoch_time
 except (KeyError, AttributeError):
  return 0

def WmiTimeToEpoch ( cimdatetime_str ) : re_match = TIME_WMI_RE . match ( cimdatetime_str ) try : t_dict = re_match . groupdict ( ) flt_time = time . strptime ( t_dict [ 'date' ] , '%Y%m%d%H%M%S' ) epoch_time = ( int ( calendar . timegm ( flt_time ) ) * 1000000 ) epoch_time += int ( t_dict [ 'subsecond' ] ) return epoch_time except ( KeyError , AttributeError ) : return 0
convert a cim_datetime string to microseconds since epoch .