code: def _to_int(value_str, min_value, rep_digit, field_name, dtarg):
          
          if '*' in value_str:
              first = value_str.index('*')
              after = value_str.rindex('*') + 1
              if value_str[first:after] != '*' * (after - first):
                  raise ValueError(
                      _format("Asterisks in {0} field of CIM datetime value "
                              "{1!A} are not consecutive: {2!A}",
                              field_name, dtarg, value_str))
              if after != len(value_str):
                  raise ValueError(
                      _format("Asterisks in {0} field of CIM datetime value "
                              "{1!A} do not end at end of field: {2!A}",
                              field_name, dtarg, value_str))
              if rep_digit is None:  # pylint: disable=no-else-return
                  # Must be an all-asterisk field
                  if first != 0:
                      raise ValueError(
                          _format("Asterisks in {0} field of CIM datetime value "
                                  "{1!A} do not start at begin of field: {2!A}",
                                  field_name, dtarg, value_str))
                  return min_value
              else:
                  value_str = value_str.replace('*', rep_digit)
          # Because the pattern and the asterisk replacement mechanism already
          # ensure only decimal digits, we expect the integer conversion to
          # always succeed.
          value = int(value_str)
          return value
docs: Convert value_str into an integer, replacing right-consecutive
          asterisks with rep_digit, and an all-asterisk value with min_value.
  
          field_name and dtarg are passed only for informational purposes.