// getDateTimePattern combines a date pattern and a time pattern into a datetime
// pattern. The datetimePattern argument includes a {0} placeholder for the time
// pattern, and a {1} placeholder for the date component.
323907
func getDateTimePattern(datetimePattern, datePattern, timePattern string) string {
	return strings.Replace(strings.Replace(datetimePattern, "{1}", datePattern, 1), "{0}", timePattern, 1)
}
607810
func (t *Translator) parseDateTimeFormat(pattern string) ([]*datetimePatternComponent, error) {
	// every thing between single quotes should become a literal
	// all non a-z, A-Z characters become a literal
	// everything else, repeat character sequences become a component
	format := []*datetimePatternComponent{}
	for i := 0; i < len(pattern); {
		char := pattern[i : i+1]

		skip := false
		// for units we don't support yet, just skip over them
		for _, r := range datetimeFormatUnitCutset {
			if char == string(r) {
				skip = true
				break
			}
		}

		if skip {
			i++
			continue
		}

		if char == string(datetimeFormatLiteral) {
			// find the next single quote
			// create a literal out of everything between the quotes
			// and set i to the position after the second quote

			if i == len(pattern)-1 {
				return []*datetimePatternComponent{}, translatorError{message: "malformed datetime format"}
			}

			nextQuote := strings.Index(pattern[i+1:], string(datetimeFormatLiteral))
			if nextQuote == -1 {
				return []*datetimePatternComponent{}, translatorError{message: "malformed datetime format"}
			}

			component := &datetimePatternComponent{
				pattern:       pattern[i+1 : nextQuote+i+1],
				componentType: datetimePatternComponentLiteral,
			}

			format = append(format, component)
			i = nextQuote + i + 2
			continue

		}
		if (char >= "a" && char <= "z") || (char >= "A" && char <= "Z") {
			// this represents a format unit
			// find the entire sequence of the same character
			endChar := lastSequenceIndex(pattern[i:]) + i

			component := &datetimePatternComponent{
				pattern:       pattern[i : endChar+1],
				componentType: datetimePatternComponentUnit,
			}

			format = append(format, component)
			i = endChar + 1
			continue

		}
		if char == string(datetimeFormatTimeSeparator) {
			component := &datetimePatternComponent{
				pattern:       t.rules.DateTime.TimeSeparator,
				componentType: datetimePatternComponentLiteral,
			}
			format = append(format, component)
			i++
			continue

		}

		component := &datetimePatternComponent{
			pattern:       char,
			componentType: datetimePatternComponentLiteral,
		}

		format = append(format, component)
		i++
		continue

	}

	return format, nil
}
664407
func FormatDateTimeField(key string, val time.Time) (string, string) {
	return key + ";VALUE=DATE-TIME", val.Format("20060102T150405")
}
259463
func (s *WebhookFilter) SetPattern(v string) *WebhookFilter {
	s.Pattern = &v
	return s
}
382935
func (c *CommitAuthor) GetDate() time.Time {
	if c == nil || c.Date == nil {
		return time.Time{}
	}
	return *c.Date
}
531908
@Override
    public String getMatchPattern() {
        String dateMatchPattern = "([mMdDnYyhHsS\\-/:]+)";
        return String.format("%s%s%s%s;%s%s%s%s, Format: %s%s",
                OPEN_RANGE_BRACKET_PATTERN,
                SPACE_DELIMITER_PATTERN,
                DATE_PATTERN,
                SPACE_DELIMITER_PATTERN,
                SPACE_DELIMITER_PATTERN,
                DATE_PATTERN,
                SPACE_DELIMITER_PATTERN,
                CLOSE_RANGE_BRACKET_PATTERN,
                SPACE_DELIMITER_PATTERN,
                dateMatchPattern);
    }
857193
func getRegEx(pattern string) *regexp.Regexp {
	for _, trs := range []struct {
		old, new string
	}{
		{".", `\.`}, // Escape all '.' in the pattern
		{"(", `\(`}, // Escape all '(' in the pattern
		{")", `\)`}, // Escape all ')' in the pattern
		{"*", ".*"}, // Replace a '*' with '.*' that matches zero or more chars
		{"{", "("},  // Change a '{' to '('
		{",", "|"},  // Change a ',' to '|'
		{"}", ")"},  // Change a '}' to ')'
		{"?", "."},  // Change a '?' to '.'
	} {
		pattern = strings.Replace(pattern, trs.old, trs.new, -1)
	}

	return regexp.MustCompile(pattern)
}
214945
func patternMatch(str string, patChars, patTypes []byte) bool {
	return stringutil.DoMatch(str, patChars, patTypes)
}
319991
func Get(typ, format string) ([]byte, error) {
	switch typ {
	case "date-only":
		return get("date_only.go")
	case "time-only":
		return get("time_only.go")
	case "datetime-only":
		return get("datetime_only.go")
	case "datetime":
		if format == "" || strings.ToUpper(format) == "RFC3339" {
			return get("datetime.go")
		} else if strings.ToUpper(format) == "RFC2616" {
			return get("datetime_rfc2616.go")
		}
	}
	return []byte{}, fmt.Errorf("unrecognized combination of type :%v format : %v", typ, format)
}
22381
func (d *DateConverter) findDateMath(node expr.Node) {

	switch n := node.(type) {
	case *expr.BinaryNode:

		for i, arg := range n.Args {
			switch narg := arg.(type) {
			case *expr.StringNode:
				val := strings.ToLower(narg.Text)
				if strings.HasPrefix(val, `now`) {

					d.TimeStrings = append(d.TimeStrings, val)

					// If left side is datemath   "now-3d" < ident then re-write to have ident on left
					var lhv value.Value
					op := n.Operator.T
					var ok bool
					if i == 0 {
						lhv, ok = Eval(d.ctx, n.Args[1])
						if !ok {
							continue
						}
						// Reverse equation to put identity on left side
						// "now-1d" < last_visit    =>   "last_visit" > "now-1d"
						switch n.Operator.T {
						case lex.TokenGT:
							op = lex.TokenLT
						case lex.TokenGE:
							op = lex.TokenLE
						case lex.TokenLT:
							op = lex.TokenGT
						case lex.TokenLE:
							op = lex.TokenGE
						default:
							// lex.TokenEqual, lex.TokenEqualEqual, lex.TokenNE:
							// none of these are supported operators for finding boundary
							continue
						}
					} else if i == 1 {
						lhv, ok = Eval(d.ctx, n.Args[0])
						if !ok {
							continue
						}
					}

					d.addValue(lhv, op, val)
					continue
				}
			default:
				d.findDateMath(arg)
			}
		}

	case *expr.BooleanNode:
		for _, arg := range n.Args {
			d.findDateMath(arg)
		}
	case *expr.UnaryNode:
		d.findDateMath(n.Arg)
	case *expr.TriNode:
		for _, arg := range n.Args {
			d.findDateMath(arg)
		}
	case *expr.FuncNode:
		for _, arg := range n.Args {
			d.findDateMath(arg)
		}
	case *expr.ArrayNode:
		for _, arg := range n.Args {
			d.findDateMath(arg)
		}
	case *expr.IncludeNode:
		if err := resolveInclude(d.ctx, n, 0); err != nil {
			d.err = err
			return
		}
		if n.ExprNode != nil {
			d.findDateMath(n.ExprNode)
		}
	case *expr.NumberNode, *expr.ValueNode, *expr.IdentityNode, *expr.StringNode:
		// Scalar/Literal values cannot be datemath, must be binary-expression
	}
}
640472
func getTimeString() string {
	timeInt := time.Now().UTC().Unix()
	timeBytes := base58.EncodeBig(nil, big.NewInt(timeInt))
	return string(timeBytes)
}
552791
func ValidatePattern(p string, val string) bool {
	knownPatternsLock.RLock()
	r, ok := knownPatterns[p]
	knownPatternsLock.RUnlock()
	if !ok {
		r = regexp.MustCompile(p) // DSL validation makes sure regexp is valid
		knownPatternsLock.Lock()
		knownPatterns[p] = r
		knownPatternsLock.Unlock()
	}
	return r.MatchString(val)
}
754537
func hasPattern(patterns []string, matchStr string) bool {
	for _, pattern := range patterns {
		if ok := wildcard.MatchSimple(pattern, matchStr); ok {
			return true
		}
	}
	return false
}
373479
private static DateTimeFormatter getSafeDateTimeFormatter(final String pattern) {
		DateTimeFormatter safeFormatter = getDateTimeFormatter(pattern);

		if (Locale.UK.equals(safeFormatter.getLocale())) {
			return safeFormatter.withLocale(Locale.ENGLISH);
		}

		return safeFormatter;
	}
1299394
func compilePattern(pattern string, escape byte) (patChars, patTypes []byte) {
	var lastAny bool
	patChars = make([]byte, len(pattern))
	patTypes = make([]byte, len(pattern))
	patLen := 0
	for i := 0; i < len(pattern); i++ {
		var tp byte
		var c = pattern[i]
		switch c {
		case escape:
			lastAny = false
			tp = patMatch
			if i < len(pattern)-1 {
				i++
				c = pattern[i]
				if c == escape || c == '_' || c == '%' {
					// valid escape.
				} else {
					// invalid escape, fall back to escape byte
					// mysql will treat escape character as the origin value even
					// the escape sequence is invalid in Go or C.
					// e.g, \m is invalid in Go, but in MySQL we will get "m" for select '\m'.
					// Following case is correct just for escape \, not for others like +.
					// TODO: add more checks for other escapes.
					i--
					c = escape
				}
			}
		case '_':
			lastAny = false
			tp = patOne
		case '%':
			if lastAny {
				continue
			}
			lastAny = true
			tp = patAny
		default:
			lastAny = false
			tp = patMatch
		}
		patChars[patLen] = c
		patTypes[patLen] = tp
		patLen++
	}
	for i := 0; i < patLen-1; i++ {
		if (patTypes[i] == patAny) && (patTypes[i+1] == patOne) {
			patTypes[i] = patOne
			patTypes[i+1] = patAny
		}
	}
	patChars = patChars[:patLen]
	patTypes = patTypes[:patLen]
	return
}
1237493
func (s *GetUserDefinedFunctionsInput) SetPattern(v string) *GetUserDefinedFunctionsInput {
	s.Pattern = &v
	return s
}
446072
func (s *OptionRestrictionRegex) SetPattern(v string) *OptionRestrictionRegex {
	s.Pattern = &v
	return s
}