def matroska_date_to_datetime(date):
 format = re.split('([-:. ])', '%Y-%m-%d %H:%M:%S.%f')
 while format:
  try:
   return datetime.strptime(date, ''.join(format))
  except ValueError:
   format = format[:(-2)]
 return date

def matroska_date_to_datetime ( date ) : format = re . split ( '([-:. ])' , '%Y-%m-%d %H:%M:%S.%f' ) while format : try : return datetime . strptime ( date , '' . join ( format ) ) except ValueError : format = format [ : ( - 2 ) ] return date
converts a date in matroskas date format to a python datetime object .