def _get_date_time_format(dt_string):
 valid_formats = ['%H:%M', '%H:%M:%S', '%m:%d:%y', '%m:%d:%Y', '%m/%d/%y', '%m/%d/%Y']
 for dt_format in valid_formats:
  try:
   datetime.strptime(dt_string, dt_format)
   return dt_format
  except ValueError:
   continue
 msg = 'Invalid Date/Time Format: {0}'.format(dt_string)
 raise SaltInvocationError(msg)

def _get_date_time_format ( dt_string ) : valid_formats = [ '%H:%M' , '%H:%M:%S' , '%m:%d:%y' , '%m:%d:%Y' , '%m/%d/%y' , '%m/%d/%Y' ] for dt_format in valid_formats : try : datetime . strptime ( dt_string , dt_format ) return dt_format except ValueError : continue msg = 'Invalid Date/Time Format: {0}' . format ( dt_string ) raise SaltInvocationError ( msg )
copied from win_system .