code: private static int countleaps( double gpsTime, boolean accum_leaps ) {
          int i, nleaps;
          double[] leaps = getleaps();
          nleaps = 0;
  
          if (accum_leaps) {
              for( i = 0; i < leaps.length; i += 1 ) {
                  if (gpsTime + i >= leaps[i]) {
                      nleaps += 1;
                  }
              }
          } else {
              for( i = 0; i < leaps.length; i += 1 ) {
                  if (gpsTime >= leaps[i]) {
                      nleaps += 1;
                  }
              }
          }
          return nleaps;
      }
docs: Count number of leap seconds that have passed