only used in ChronoFormatter.parseElements()
339816
void putAll(ParsedValues other) {

        if (this.keys == null) {
            int v = other.len;
            if (v != Integer.MIN_VALUE) {
                if ((this.len == Integer.MIN_VALUE) || this.duplicateKeysAllowed || (this.len == v)) {
                    this.len = v;
                } else {
                    throw new AmbivalentValueException(PlainTime.DIGITAL_HOUR_OF_DAY);
                }
            }
            v = other.mask;
            if (v != Integer.MIN_VALUE) {
                if ((this.mask == Integer.MIN_VALUE) || this.duplicateKeysAllowed || (this.mask == v)) {
                    this.mask = v;
                } else {
                    throw new AmbivalentValueException(PlainTime.MINUTE_OF_HOUR);
                }
            }
            v = other.threshold;
            if (v != Integer.MIN_VALUE) {
                if ((this.threshold == Integer.MIN_VALUE) || this.duplicateKeysAllowed || (this.threshold == v)) {
                    this.threshold = v;
                } else {
                    throw new AmbivalentValueException(PlainTime.SECOND_OF_MINUTE);
                }
            }
            v = other.count;
            if (v != Integer.MIN_VALUE) {
                if ((this.count == Integer.MIN_VALUE) || this.duplicateKeysAllowed || (this.count == v)) {
                    this.count = v;
                } else {
                    throw new AmbivalentValueException(PlainTime.NANO_OF_SECOND);
                }
            }
            for (int i = 0; i < 3; i++) {
                v = other.ints[i];
                if (v != Integer.MIN_VALUE) {
                    if ((this.ints[i] == Integer.MIN_VALUE) || this.duplicateKeysAllowed || (this.ints[i] == v)) {
                        this.ints[i] = v;
                    } else {
                        throw new AmbivalentValueException(getIndexedElement(i));
                    }
                }
            }
            Map<ChronoElement<?>, Object> m = other.map;
            if (m != null) {
                for (ChronoElement<?> e : m.keySet()) {
                    this.put(e, m.get(e));
                }
            }
            return;
        }

        Object[] elements = other.keys;
        Object current;

        for (int i = 0; i < elements.length; i++) {
            if ((current = elements[i]) != null) {
                ChronoElement<?> element = ChronoElement.class.cast(current);
                if (element.getType() == Integer.class) {
                    this.put(element, other.ints[i]);
                } else {
                    this.put(element, other.values[i]);
                }
            }
        }

    }
669166
@Override
    public <V> V getMinimum(ChronoElement<V> element) {

        if (this.timestamp.contains(element)) {
            return this.timestamp.getMinimum(element);
        } else {
            return this.moment.getMinimum(element);
        }

    }
96544
private static long parseDuration(String value) throws ParseException {
    // Must ended with "s".
    if (value.isEmpty() || value.charAt(value.length() - 1) != 's') {
      throw new ParseException("Invalid duration string: " + value, 0);
    }
    boolean negative = false;
    if (value.charAt(0) == '-') {
      negative = true;
      value = value.substring(1);
    }
    String secondValue = value.substring(0, value.length() - 1);
    String nanoValue = "";
    int pointPosition = secondValue.indexOf('.');
    if (pointPosition != -1) {
      nanoValue = secondValue.substring(pointPosition + 1);
      secondValue = secondValue.substring(0, pointPosition);
    }
    long seconds = Long.parseLong(secondValue);
    int nanos = nanoValue.isEmpty() ? 0 : parseNanos(nanoValue);
    if (seconds < 0) {
      throw new ParseException("Invalid duration string: " + value, 0);
    }
    if (negative) {
      seconds = -seconds;
      nanos = -nanos;
    }
    try {
      return normalizedDuration(seconds, nanos);
    } catch (IllegalArgumentException e) {
      throw new ParseException("Duration value is out of range.", 0);
    }
  }
84353
private static Interval parseStartExtended(CharSequence startStr, CharSequence endStr) {
        Instant start = Instant.parse(startStr);
        if (endStr.length() > 0) {
            char c = endStr.charAt(0);
            if (c == 'P' || c == 'p') {
                PeriodDuration amount = PeriodDuration.parse(endStr);
                // addition of PeriodDuration only supported by OffsetDateTime,
                // but to make that work need to move point being added to closer to EPOCH
                long move = start.isBefore(Instant.EPOCH) ? 1000 * 86400 : -1000 * 86400;
                Instant end = start.plusSeconds(move).atOffset(ZoneOffset.UTC).plus(amount).toInstant().minusSeconds(move);
                return Interval.of(start, end);
            }
        }
        // infer offset from start if not specified by end
        return parseEndDateTime(start, ZoneOffset.UTC, endStr);
    }
77633
static void checkNegativeLS(
        long posixTime,
        PlainTimestamp ts
    ) {

        LeapSeconds ls = LeapSeconds.getInstance();

        if (
            ls.supportsNegativeLS()
            && (ls.strip(ls.enhance(posixTime)) > posixTime)
        ) {
            throw new ChronoException(
                "Illegal local timestamp due to "
                + "negative leap second: " + ts);
        }

    }
227090
private static <U extends IsoUnit> Duration<U> parsePeriod(
        String period,
        Class<U> type
    ) throws ParseException {

        int index = 0;
        boolean negative = false;

        if (period.length() == 0) {
            throw new ParseException("Empty period string.", index);
        } else if (period.charAt(0) == '-') {
            negative = true;
            index = 1;
        }

        try {

            if (period.charAt(index) != 'P') {
                throw new ParseException(
                    "Format symbol \'P\' expected: " + period, index);
            } else {
                index++;
            }

            List<Item<U>> items = new ArrayList<>();
            int sep = period.indexOf('T', index);
            boolean calendrical = (sep == -1);
            int typeID = SUPER_TYPE;

            if (type == CalendarUnit.class) {
                typeID = CALENDAR_TYPE;
            } else if (type == ClockUnit.class) {
                typeID = CLOCK_TYPE;
            } else if (type == IsoDateUnit.class) {
                typeID = WEEK_BASED_TYPE;
            }

            if (calendrical) {
                if (typeID == CLOCK_TYPE) {
                    throw new ParseException("Format symbol \'T\' expected: " + period, index);
                } else {
                    parse(period, index, period.length(), ((typeID == SUPER_TYPE) ? CALENDAR_TYPE : typeID), items);
                }
            } else if ((typeID == CALENDAR_TYPE) || (typeID == WEEK_BASED_TYPE)) {
                throw new ParseException("Unexpected time component found: " + period, sep);
            } else {
                boolean alternative = false;
                if (sep > index) {
                    if (typeID == CLOCK_TYPE) {
                        throw new ParseException(
                            "Unexpected date component found: " + period,
                            index);
                    } else {
                        alternative = parse(period.substring(0, sep), index, sep, CALENDAR_TYPE, items);
                    }
                }
                if (alternative) {
                    parseAlt(period, sep + 1, period.length(), false, items);
                } else {
                    parse(period, sep + 1, period.length(), CLOCK_TYPE, items);
                }
            }

            return new Duration<>(items, negative);

        } catch (IndexOutOfBoundsException ex) {
            ParseException pe =
                new ParseException(
                    "Unexpected termination of period string: " + period,
                    index);
            pe.initCause(ex);
            throw pe;
        }

    }
1035512
function lb__processRelativeTime(number, withoutSuffix, key, isFuture) {
        var format = {
            'm': ['eng Minutt', 'enger Minutt'],
            'h': ['eng Stonn', 'enger Stonn'],
            'd': ['een Dag', 'engem Dag'],
            'M': ['ee Mount', 'engem Mount'],
            'y': ['ee Joer', 'engem Joer']
        };
        return withoutSuffix ? format[key][0] : format[key][1];
    }
1306407
private Long trySeconds(String str) {

        for(String pattern : datePatterns) {

            SimpleDateFormat parser = new SimpleDateFormat(pattern, locale);

            try {
                long milliseconds = parser.parse(str).getTime();
                return milliseconds / 1000L;
            }
            catch(Exception e) {
                // Just ignore and try the next pattern in `datePatterns`.
            }
        }

        // Could not parse the string into a meaningful date, return null.
        return null;
    }
49770
def parse_time(time):
    """"""
    if isinstance(time, datetime.datetime):
        return time
    return datetime.datetime.strptime(time, DATETIME_FORMAT_OPENVPN)
422982
private static long parseToTimeMillis(String dateStr, TimeZone tz) {
		String format;
		if (dateStr.length() <= 10) {
			format = DATE_FORMAT_STRING;
		} else {
			format = TIMESTAMP_FORMAT_STRING;
		}
		return parseToTimeMillis(dateStr, format, tz) + getMillis(dateStr);
	}
7427
Token parseTerm() throws ParseException {
		int ch = this.read();
		Token tok = null;
		if (ch == T_OR || ch == T_RPAREN || ch == T_EOF) {
			tok = Token.createEmpty();
		} else {
			tok = this.parseFactor();
			Token concat = null;
			while ((ch = this.read()) != T_OR && ch != T_RPAREN && ch != T_EOF) {
				if (concat == null) {
					concat = Token.createConcat();
					concat.addChild(tok);
					tok = concat;
				}
				concat.addChild(this.parseFactor());
				// tok = Token.createConcat(tok, this.parseFactor());
			}
		}
		if (ch == T_RPAREN) {
			parenCount--;
		}
		return tok;
	}
1296983
void parseDocument(
            final char[] buffer, final int offset, final int len,
            final IMarkupHandler handler, final ParseStatus status)
            throws ParseException {


        final long parsingStartTimeNanos = System.nanoTime();

        try {

            handler.handleDocumentStart(parsingStartTimeNanos, 1, 1);

            status.offset = -1;
            status.line = 1;
            status.col = 1;
            status.inStructure = false;
            status.parsingDisabled = true;
            status.parsingDisabledLimitSequence = null;
            status.autoCloseRequired = null;
            status.autoCloseLimits = null;

            parseBuffer(buffer, offset, len, handler, status);

            // First parse done, now it's time to clean up in case we still have some text to be notified

            int lastLine = status.line;
            int lastCol = status.col;

            final int lastStart = status.offset;
            final int lastLen = (offset + len) - lastStart;

            if (lastLen > 0) {

                if (status.inStructure) {
                    throw new ParseException(
                            "Incomplete structure: \"" + new String(buffer, lastStart, lastLen) + "\"", status.line, status.col);
                }

                handler.handleText(buffer, lastStart, lastLen, status.line, status.col);

                // As we have produced an additional text event, we need to fast-forward the
                // lastLine and lastCol position to include the last text structure.
                for (int i = lastStart; i < (lastStart + lastLen); i++) {
                    final char c = buffer[i];
                    if (c == '\n') {
                        lastLine++;
                        lastCol = 1;
                    } else {
                        lastCol++;
                    }

                }

            }

            final long parsingEndTimeNanos = System.nanoTime();
            handler.handleDocumentEnd(parsingEndTimeNanos, (parsingEndTimeNanos - parsingStartTimeNanos), lastLine, lastCol);

        } catch (final ParseException e) {
            throw e;
        } catch (final Exception e) {
            throw new ParseException(e);
        }

    }
107207
public void findTimexes(String timexType, 
							HashMap<Pattern, String> hmPattern,
							HashMap<String, String> hmOffset,
							HashMap<String, String> hmNormalization,
							Sentence s,
							JCas jcas) {
		RuleManager rm = RuleManager.getInstance(language, find_temponyms);
		HashMap<String, String> hmDatePosConstraint = rm.getHmDatePosConstraint();
		HashMap<String, String> hmDurationPosConstraint = rm.getHmDurationPosConstraint();
		HashMap<String, String> hmTimePosConstraint = rm.getHmTimePosConstraint();
		HashMap<String, String> hmSetPosConstraint = rm.getHmSetPosConstraint();
		HashMap<String, String> hmTemponymPosConstraint = rm.getHmTemponymPosConstraint();
		
		// get fast check patterns first
		HashMap<String, Pattern> hmDateFastCheck = rm.getHmDateFastCheck();
		HashMap<String, Pattern> hmDurationFastCheck = rm.getHmDurationFastCheck();
		HashMap<String, Pattern> hmTimeFastCheck = rm.getHmTimeFastCheck();
		HashMap<String, Pattern> hmSetFastCheck = rm.getHmSetFastCheck();
		HashMap<String, Pattern> hmTemponymFastCheck = rm.getHmTemponymFastCheck();
		Pattern f = null;
		Boolean fastCheckOK = true;
		
		// Iterator over the rules by sorted by the name of the rules
		// this is important since later, the timexId will be used to 
		// decide which of two expressions shall be removed if both
		// have the same offset
		for (Iterator<Pattern> i = Toolbox.sortByValue(hmPattern).iterator(); i.hasNext(); ) {
            Pattern p = (Pattern) i.next();
            
            // validate fast check fist, if no fast match, everything else is not required anymore
            if (timexType.equals("DATE")) {
            	f = hmDateFastCheck.get(hmPattern.get(p));
            } else if (timexType.equals("Time")) {
            	f = hmTimeFastCheck.get(hmPattern.get(p));
            } else if (timexType.equals("DURATION")) {
            	f = hmDurationFastCheck.get(hmPattern.get(p));
            } else if (timexType.equals("SET")) {
            	f = hmSetFastCheck.get(hmPattern.get(p));
            } else if (timexType.equals("TEMPONYM")) {
            	f = hmTemponymFastCheck.get(hmPattern.get(p));
            } 
			if (!(f == null)){
				fastCheckOK = false;
				
				if (f.matcher(s.getCoveredText()).find()) {
					fastCheckOK = true;
				}
			}
			
            
			if (fastCheckOK) {
				for (MatchResult r : Toolbox.findMatches(p, s.getCoveredText())) {
					boolean infrontBehindOK = ContextAnalyzer.checkTokenBoundaries(r, s, jcas) // improved token boundary checking
										&& ContextAnalyzer.checkInfrontBehind(r, s);
	
					
					// CHECK POS CONSTRAINTS
					boolean posConstraintOK = true;
					
					if (timexType.equals("DATE")) {
						if (hmDatePosConstraint.containsKey(hmPattern.get(p))) {
							posConstraintOK = checkPosConstraint(s , hmDatePosConstraint.get(hmPattern.get(p)), r, jcas);
						}
					} else if (timexType.equals("DURATION")) {
						if (hmDurationPosConstraint.containsKey(hmPattern.get(p))) {
							posConstraintOK = checkPosConstraint(s , hmDurationPosConstraint.get(hmPattern.get(p)), r, jcas);
						}					
					} else if (timexType.equals("TIME")) {
						if (hmTimePosConstraint.containsKey(hmPattern.get(p))) {
							posConstraintOK = checkPosConstraint(s , hmTimePosConstraint.get(hmPattern.get(p)), r, jcas);
						}
					} else if (timexType.equals("SET")) {
						if (hmSetPosConstraint.containsKey(hmPattern.get(p))) {
							posConstraintOK = checkPosConstraint(s , hmSetPosConstraint.get(hmPattern.get(p)), r, jcas);
						}
					} else if (timexType.equals("TEMPONYM")) {
						if (hmTemponymPosConstraint.containsKey(hmPattern.get(p))) {
							posConstraintOK = checkPosConstraint(s , hmSetPosConstraint.get(hmPattern.get(p)), r, jcas);
						}
					}
					
					if ((infrontBehindOK == true) && (posConstraintOK == true)) {
						
						// Offset of timex expression (in the checked sentence)
						int timexStart = r.start();
						int timexEnd   = r.end();
						
						// Normalization from Files:
						
						// Any offset parameter?
						if (hmOffset.containsKey(hmPattern.get(p))) {
							String offset    = hmOffset.get(hmPattern.get(p));
					
							// pattern for offset information
							Pattern paOffset = Pattern.compile("group\\(([0-9]+)\\)-group\\(([0-9]+)\\)");
							for (MatchResult mr : Toolbox.findMatches(paOffset,offset)) {
								int startOffset = Integer.parseInt(mr.group(1));
								int endOffset   = Integer.parseInt(mr.group(2));
								timexStart = r.start(startOffset);
								timexEnd   = r.end(endOffset); 
							}
						}
						
						// Normalization Parameter
						if (hmNormalization.containsKey(hmPattern.get(p))) {
							String[] attributes = new String[5];
							if (timexType.equals("DATE")) {
								attributes = getAttributesForTimexFromFile(hmPattern.get(p), rm.getHmDateNormalization(), rm.getHmDateQuant(), rm.getHmDateFreq(), rm.getHmDateMod(), rm.getHmDateEmptyValue(), r, jcas);
							} else if (timexType.equals("DURATION")) {
								attributes = getAttributesForTimexFromFile(hmPattern.get(p), rm.getHmDurationNormalization(), rm.getHmDurationQuant(), rm.getHmDurationFreq(), rm.getHmDurationMod(), rm.getHmDurationEmptyValue(), r, jcas);
							} else if (timexType.equals("TIME")) {
								attributes = getAttributesForTimexFromFile(hmPattern.get(p), rm.getHmTimeNormalization(), rm.getHmTimeQuant(), rm.getHmTimeFreq(), rm.getHmTimeMod(), rm.getHmTimeEmptyValue(), r, jcas);
							} else if (timexType.equals("SET")) {
								attributes = getAttributesForTimexFromFile(hmPattern.get(p), rm.getHmSetNormalization(), rm.getHmSetQuant(), rm.getHmSetFreq(), rm.getHmSetMod(), rm.getHmSetEmptyValue(), r, jcas);
							} else if (timexType.equals("TEMPONYM")) {
								attributes = getAttributesForTimexFromFile(hmPattern.get(p), rm.getHmTemponymNormalization(), rm.getHmTemponymQuant(), rm.getHmTemponymFreq(), rm.getHmTemponymMod(), rm.getHmTemponymEmptyValue(), r, jcas);
							}
							if (!(attributes == null)) {
								addTimexAnnotation(timexType, timexStart + s.getBegin(), timexEnd + s.getBegin(), s, 
										attributes[0], attributes[1], attributes[2], attributes[3], attributes[4], "t" + timexID++, hmPattern.get(p), jcas);
							}
						}
						else {
							Logger.printError("SOMETHING REALLY WRONG HERE: "+hmPattern.get(p));
						}
					}
				}
			}
			fastCheckOK = true;
		}
	}
118231
function parseMatchTime(matchTime) {

    /** @type String[] */
    var matchTimeArr = matchTime.split(' ');
    matchTimeArr = [matchTimeArr[1], matchTimeArr[3]];
    var dayMonthYear = matchTimeArr[0].split('.');
    var hourMinutes = matchTimeArr[1].split(':');
    var date = new Date(dayMonthYear[2], parseInt(dayMonthYear[1]) - 1, dayMonthYear[0], hourMinutes[0], hourMinutes[1]);

    return date;
}
674534
def parse_time_indices(s):
  
  if not s.startswith('['):
    s = '[' + s + ']'
  parsed = command_parser._parse_slices(s)
  if len(parsed) != 1:
    raise ValueError(
        'Invalid number of slicing objects in time indices (%d)' % len(parsed))
  else:
    return parsed[0]
1195715
def _parse(text, **options):
    
    # Handling special cases
    if text == "now":
        return pendulum.now()

    parsed = base_parse(text, **options)

    if isinstance(parsed, datetime.datetime):
        return pendulum.datetime(
            parsed.year,
            parsed.month,
            parsed.day,
            parsed.hour,
            parsed.minute,
            parsed.second,
            parsed.microsecond,
            tz=parsed.tzinfo or options.get("tz", UTC),
        )

    if isinstance(parsed, datetime.date):
        return pendulum.date(parsed.year, parsed.month, parsed.day)

    if isinstance(parsed, datetime.time):
        return pendulum.time(
            parsed.hour, parsed.minute, parsed.second, parsed.microsecond
        )

    if isinstance(parsed, _Interval):
        if parsed.duration is not None:
            duration = parsed.duration

            if parsed.start is not None:
                dt = pendulum.instance(parsed.start, tz=options.get("tz", UTC))

                return pendulum.period(
                    dt,
                    dt.add(
                        years=duration.years,
                        months=duration.months,
                        weeks=duration.weeks,
                        days=duration.remaining_days,
                        hours=duration.hours,
                        minutes=duration.minutes,
                        seconds=duration.remaining_seconds,
                        microseconds=duration.microseconds,
                    ),
                )

            dt = pendulum.instance(parsed.end, tz=options.get("tz", UTC))

            return pendulum.period(
                dt.subtract(
                    years=duration.years,
                    months=duration.months,
                    weeks=duration.weeks,
                    days=duration.remaining_days,
                    hours=duration.hours,
                    minutes=duration.minutes,
                    seconds=duration.remaining_seconds,
                    microseconds=duration.microseconds,
                ),
                dt,
            )

        return pendulum.period(
            pendulum.instance(parsed.start, tz=options.get("tz", UTC)),
            pendulum.instance(parsed.end, tz=options.get("tz", UTC)),
        )

    if CDuration and isinstance(parsed, CDuration):
        return pendulum.duration(
            years=parsed.years,
            months=parsed.months,
            weeks=parsed.weeks,
            days=parsed.days,
            hours=parsed.hours,
            minutes=parsed.minutes,
            seconds=parsed.seconds,
            microseconds=parsed.microseconds,
        )

    return parsed
1351593
protected void parseElse() {
        Node parent = peek();
        if (!(parent instanceof IfNode)) {
            return;
        }
        IfNode ifNode = (IfNode) pop();
        ElseNode elseNode = new ElseNode();
        ifNode.setElseNode(elseNode);
        push(elseNode);
        tokenizer.skipWhitespace();
    }