isValidTimeDef(text) {
    const parsedDefs = this.parseTimeDefinitions(text);
    if (parsedDefs === null) {
      return false;
    }

    const totalDefs = this.definitions.concat(parsedDefs);

    for (let i = 0; i < totalDefs.length; i++) {
      if (totalDefs[i].shiftType === ShiftTypes.predefined && totalDefs.length > 1) {
        return false;
      }
    }

    let foundDaysOrGreater = false;
    let foundDayOfWeek = false;
    for (let i = 0; i < totalDefs.length; i++) {
      // Definitions greater than hours are not allowed in the same arg as dayofweek.
      if (
        totalDefs[i].shiftType === ShiftTypes.days ||
        totalDefs[i].shiftType === ShiftTypes.weeks ||
        totalDefs[i].shiftType === ShiftTypes.months ||
        totalDefs[i].shiftType === ShiftTypes.years
      ) {
        foundDaysOrGreater = true;
        if (foundDayOfWeek) {
          return false;
        }
      } else if (totalDefs[i].shiftType === ShiftTypes.dayofweek) {
        foundDayOfWeek = true;
        if (foundDaysOrGreater) {
          return false;
        }
      }

      for (let j = 0; j < totalDefs.length; j++) {
        if (i === j) {
          continue;
        }

        if (totalDefs[i].shiftType === totalDefs[j].shiftType) {
          return false;
        }
      }
    }

    return true;
  }
/**
   * Checks if a given text determines a time definition which can be appended to this arg.
   * Two definitions of the same type are not allowed in the same arg.
   * Some other restriction also apply (for example, cannot set months if dayofweek is set).
   * @param  {string}  text the text to be parsed
   * @return {Boolean}      true if a valid definition and can be appended
   */
Checks if a given text determines a time definition which can be appended to this arg.
Two definitions of the same type are not allowed in the same arg.
Some other restriction also apply (for example, cannot set months if dayofweek is set).
@param  {string}  text the text to be parsed
@return {Boolean}      true if a valid definition and can be appended
Checks if a given text determines a time definition which can be appended to this arg . Two definitions of the same type are not allowed in the same arg . Some other restriction also apply ( for example cannot set months if dayofweek is set ) . @param { string } text the text to be parsed @return { Boolean } true if a valid definition and can be appended
isValidTimeDef(text) {
    const parsedDefs = this.parseTimeDefinitions(text);
    if (parsedDefs === null) {
      return false;
    }
    const totalDefs = this.definitions.concat(parsedDefs);
    for (let i = 0; i < totalDefs.length; i++) {
      if (totalDefs[i].shiftType === ShiftTypes.predefined && totalDefs.length > 1) {
        return false;
      }
    }
    let foundDaysOrGreater = false;
    let foundDayOfWeek = false;
    for (let i = 0; i < totalDefs.length; i++) {
      if (
        totalDefs[i].shiftType === ShiftTypes.days ||
        totalDefs[i].shiftType === ShiftTypes.weeks ||
        totalDefs[i].shiftType === ShiftTypes.months ||
        totalDefs[i].shiftType === ShiftTypes.years
      ) {
        foundDaysOrGreater = true;
        if (foundDayOfWeek) {
          return false;
        }
      } else if (totalDefs[i].shiftType === ShiftTypes.dayofweek) {
        foundDayOfWeek = true;
        if (foundDaysOrGreater) {
          return false;
        }
      }
      for (let j = 0; j < totalDefs.length; j++) {
        if (i === j) {
          continue;
        }
        if (totalDefs[i].shiftType === totalDefs[j].shiftType) {
          return false;
        }
      }
    }
    return true;
  }
isValidTimeDef ( text ) { const parsedDefs = this . parseTimeDefinitions ( text ) ; if ( parsedDefs === null ) { return false ; } const totalDefs = this . definitions . concat ( parsedDefs ) ; for ( let i = 0 ; i < totalDefs . length ; i ++ ) { if ( totalDefs [ i ] . shiftType === ShiftTypes . predefined && totalDefs . length > 1 ) { return false ; } } let foundDaysOrGreater = false ; let foundDayOfWeek = false ; for ( let i = 0 ; i < totalDefs . length ; i ++ ) { if ( totalDefs [ i ] . shiftType === ShiftTypes . days || totalDefs [ i ] . shiftType === ShiftTypes . weeks || totalDefs [ i ] . shiftType === ShiftTypes . months || totalDefs [ i ] . shiftType === ShiftTypes . years ) { foundDaysOrGreater = true ; if ( foundDayOfWeek ) { return false ; } } else if ( totalDefs [ i ] . shiftType === ShiftTypes . dayofweek ) { foundDayOfWeek = true ; if ( foundDaysOrGreater ) { return false ; } } for ( let j = 0 ; j < totalDefs . length ; j ++ ) { if ( i === j ) { continue ; } if ( totalDefs [ i ] . shiftType === totalDefs [ j ] . shiftType ) { return false ; } } } return true ; }
Checks if a given text determines a time definition which can be appended to this arg.
Checks if a given text determines a time definition which can be appended to this arg .
// Definitions greater than hours are not allowed in the same arg as dayofweek.