parseTimeDefinitions(text) {
    if (text === undefined || text === null || text === '') {
      return null;
    }

    // Firstly check predefined definitions.
    if (text === this.langManager.getString(TimeArgPredefinedValues.today)) {
      const currentDate = new Date();
      const inDayTimeTimestamp =
        ((currentDate.getHours() * 60 + currentDate.getMinutes()) * 60 + currentDate.getSeconds()) * 1000;
      return [{ amount: inDayTimeTimestamp, shiftType: ShiftTypes.predefined }];
    }

    if (text === this.langManager.getString(TimeArgPredefinedValues.all)) {
      const currentDate = new Date();
      return [{ amount: currentDate.getTime(), shiftType: ShiftTypes.predefined }];
    }

    // Some definition types apply only for certain time type (distance, one-shot schedule, recurrent schedule)
    if (this.timeType !== TimeTypes.distance) {
      const year = this.tryParseYearDefinition(text);
      if (year !== null) {
        return year;
      }

      const month = this.tryParseMonthDefinition(text);
      if (month !== null) {
        return month;
      }

      const day = this.tryParseDayDefinition(text);
      if (day !== null) {
        return day;
      }

      const timezone = this.tryParseTimezoneDefinition(text);
      if (timezone !== null) {
        return timezone;
      }

      const dayOfWeek = this.tryParseDayOfWeekDefinition(text);
      if (dayOfWeek !== null) {
        return dayOfWeek;
      }
    }

    const hoursMinutesSeconds = this.tryParseHoursMinutesSecondsDefinition(text);
    if (hoursMinutesSeconds !== null) {
      return hoursMinutesSeconds;
    }

    // Finally, try to parse at least definition in the form of time distance, like "3h 10m 20s"
    return this.tryParseDistance(text);
  }
/**
   * Parses time definitions for a given text. For example, 20 minutes, 10 seconds, 1 year etc.
   * @param  {string}        text text to parse
   * @return {Array<Object>}      the array of parsed definitions, each containing the shift time and shift amount
   */
Parses time definitions for a given text. For example, 20 minutes, 10 seconds, 1 year etc.
@param  {string}        text text to parse
@return {Array}      the array of parsed definitions, each containing the shift time and shift amount
Parses time definitions for a given text . For example 20 minutes 10 seconds 1 year etc . @param { string } text text to parse @return { Array } the array of parsed definitions each containing the shift time and shift amount
parseTimeDefinitions(text) {
    if (text === undefined || text === null || text === '') {
      return null;
    }
    if (text === this.langManager.getString(TimeArgPredefinedValues.today)) {
      const currentDate = new Date();
      const inDayTimeTimestamp =
        ((currentDate.getHours() * 60 + currentDate.getMinutes()) * 60 + currentDate.getSeconds()) * 1000;
      return [{ amount: inDayTimeTimestamp, shiftType: ShiftTypes.predefined }];
    }
    if (text === this.langManager.getString(TimeArgPredefinedValues.all)) {
      const currentDate = new Date();
      return [{ amount: currentDate.getTime(), shiftType: ShiftTypes.predefined }];
    }
    if (this.timeType !== TimeTypes.distance) {
      const year = this.tryParseYearDefinition(text);
      if (year !== null) {
        return year;
      }
      const month = this.tryParseMonthDefinition(text);
      if (month !== null) {
        return month;
      }
      const day = this.tryParseDayDefinition(text);
      if (day !== null) {
        return day;
      }
      const timezone = this.tryParseTimezoneDefinition(text);
      if (timezone !== null) {
        return timezone;
      }
      const dayOfWeek = this.tryParseDayOfWeekDefinition(text);
      if (dayOfWeek !== null) {
        return dayOfWeek;
      }
    }
    const hoursMinutesSeconds = this.tryParseHoursMinutesSecondsDefinition(text);
    if (hoursMinutesSeconds !== null) {
      return hoursMinutesSeconds;
    }
    return this.tryParseDistance(text);
  }
parseTimeDefinitions ( text ) { if ( text === undefined || text === null || text === '' ) { return null ; } if ( text === this . langManager . getString ( TimeArgPredefinedValues . today ) ) { const currentDate = new Date ( ) ; const inDayTimeTimestamp = ( ( currentDate . getHours ( ) * 60 + currentDate . getMinutes ( ) ) * 60 + currentDate . getSeconds ( ) ) * 1000 ; return [ { amount : inDayTimeTimestamp , shiftType : ShiftTypes . predefined } ] ; } if ( text === this . langManager . getString ( TimeArgPredefinedValues . all ) ) { const currentDate = new Date ( ) ; return [ { amount : currentDate . getTime ( ) , shiftType : ShiftTypes . predefined } ] ; } if ( this . timeType !== TimeTypes . distance ) { const year = this . tryParseYearDefinition ( text ) ; if ( year !== null ) { return year ; } const month = this . tryParseMonthDefinition ( text ) ; if ( month !== null ) { return month ; } const day = this . tryParseDayDefinition ( text ) ; if ( day !== null ) { return day ; } const timezone = this . tryParseTimezoneDefinition ( text ) ; if ( timezone !== null ) { return timezone ; } const dayOfWeek = this . tryParseDayOfWeekDefinition ( text ) ; if ( dayOfWeek !== null ) { return dayOfWeek ; } } const hoursMinutesSeconds = this . tryParseHoursMinutesSecondsDefinition ( text ) ; if ( hoursMinutesSeconds !== null ) { return hoursMinutesSeconds ; } return this . tryParseDistance ( text ) ; }
Parses time definitions for a given text.
Parses time definitions for a given text .
// Firstly check predefined definitions. // Some definition types apply only for certain time type (distance, one-shot schedule, recurrent schedule) // Finally, try to parse at least definition in the form of time distance, like "3h 10m 20s"