docs: static int dayNumToDate(Weekday dow0, int nDays, int weekNum,
                              Weekday dow, int d0, int nDaysInMonth) {
          // if dow is wednesday, then this is the date of the first wednesday
          int firstDateOfGivenDow = 1 + ((7 + dow.javaDayNum - dow0.javaDayNum) % 7);
  
          int date;
          if (weekNum > 0) {
              date = ((weekNum - 1) * 7) + firstDateOfGivenDow - d0;
          } else {  // count weeks from end of month
              // calculate last day of the given dow.
              // Since nDays <= 366, this should be > nDays
              int lastDateOfGivenDow = firstDateOfGivenDow + (7 * 54);
              lastDateOfGivenDow -= 7 * ((lastDateOfGivenDow - nDays + 6) / 7);
              date = lastDateOfGivenDow + 7 * (weekNum + 1) - d0;
          }
          if (date <= 0 || date > nDaysInMonth) {
              return 0;
          }
          return date;
      }