code: private int matchDayPeriodString(String text, int start, String[] data, int dataLength,
              Output<DayPeriodRules.DayPeriod> dayPeriod)
      {
          int bestMatchLength = 0, bestMatch = -1;
          int matchLength = 0;
          for (int i = 0; i < dataLength; ++i) {
              // Only try matching if the string exists.
              if (data[i] != null) {
                  int length = data[i].length();
                  if (length > bestMatchLength &&
                          (matchLength = regionMatchesWithOptionalDot(text, start, data[i], length)) >= 0) {
                      bestMatch = i;
                      bestMatchLength = matchLength;
                  }
              }
          }
  
          if (bestMatch >= 0) {
              dayPeriod.value = DayPeriodRules.DayPeriod.VALUES[bestMatch];
              return start + bestMatchLength;
          }
  
          return -start;
      }
docs: Similar to matchQuarterString but customized for day periods.