// NormalizeYYYYMMDD matches optional non-digits, 4 digits, optional non-digits,
// 2 digits, optional non-digits, 2 digits, optional non-digits
// Returns those 8 digits formatted as "dddd.dd.dd", or error if unparseable.
503654
func NormalizeYYYYMMDD(s string) (string, error) {
	match := yyyymmddMatcher.FindStringSubmatch(s)
	if match == nil {
		return "", fmt.Errorf("could not parse '%s' as yyyymmdd", s)
	}
	return fmt.Sprintf("%s.%s.%s", match[1], match[2], match[3]), nil
}
784918
func goNormalize(s string) string {
	fmtd := xstrings.ToCamelCase(s)
	return formatID(s, fmtd)
}
11888
func Digits(digits int) string {
	max := int(math.Pow10(digits)) - 1
	num := privateRand.Intn(max)
	format := fmt.Sprintf("%%0%dd", digits)
	return fmt.Sprintf(format, num)
}
243201
func NormalizeDomain(domain string) string {
	// Trim whitespace.
	domain = strings.TrimSpace(domain)
	// Check validity.
	if !IsValidDomain(domain) {
		return ""
	}
	// Remove trailing dot.
	domain = strings.TrimRight(domain, ".")
	// Convert to lower case.
	domain = strings.ToLower(domain)
	return domain
}
135813
func xyzToLabAB(x, y, z float64) (float64, float64, float64) {
	normalizedX := x / 95.047
	normalizedY := y / 100.0
	normalizedZ := z / 108.883

	if normalizedX > 0.008856 {
		normalizedX = math.Pow(normalizedX, (1.0 / 3.0))
	} else {
		normalizedX = (7.787 * normalizedX) + (16.0 / 116.0)
	}

	if normalizedY > 0.008856 {
		normalizedY = math.Pow(normalizedY, (1.0 / 3.0))
	} else {
		normalizedY = (7.787 * normalizedY) + (16.0 / 116.0)
	}

	if normalizedZ > 0.008856 {
		normalizedZ = math.Pow(normalizedZ, (1.0 / 3.0))
	} else {
		normalizedZ = (7.787 * normalizedZ) + (16.0 / 116.0)
	}

	l := (116 * normalizedY) - 16
	a := 500 * (normalizedX - normalizedY)
	b := 200 * (normalizedY - normalizedZ)

	return l, a, b
}
1307842
func generateKeyPrefixID(prefix []byte, id uint64) []byte {
	// Handle the prefix.
	key := append(prefix, prefixDelimiter)

	// Handle the item ID.
	key = append(key, idToKey(id)...)

	return key
}
994528
func SafeAdd(x, y uint64) (uint64, bool) {
	return x + y, y > MaxUint64-x
}
407438
func (m *Module) Normalized() string {
	return m.formatWithPrefix(m.normalizedHostPrefix(m.Host().Normalized()), false)
}
922372
func GenerateIDWithAlg(customIDgenAlg string, payload []byte) (string, error) {
	if customIDgenAlg == "" {
		customIDgenAlg = defaultAlg
	}
	var alg = availableIDgenAlgs[customIDgenAlg]
	if alg.hashFun != nil {
		return alg.hashFun(payload), nil
	}
	return "", fmt.Errorf("Wrong ID generation algorithm was given: %s", customIDgenAlg)
}
1090389
func (m NiceMD) Del(key string) NiceMD {
	k, _ := encodeKeyValue(key, "")
	delete(m, k)
	return m
}
790987
func FormatBytes(i int64) (result string) {
	switch {
	case i > (1024 * 1024 * 1024 * 1024):
		result = fmt.Sprintf("%.02f TiB", float64(i)/1024/1024/1024/1024)
	case i > (1024 * 1024 * 1024):
		result = fmt.Sprintf("%.02f GiB", float64(i)/1024/1024/1024)
	case i > (1024 * 1024):
		result = fmt.Sprintf("%.02f MiB", float64(i)/1024/1024)
	case i > 1024:
		result = fmt.Sprintf("%.02f KiB", float64(i)/1024)
	default:
		result = fmt.Sprintf("%d B", i)
	}
	result = strings.Trim(result, " ")
	return
}
1245093
func (s *State) EmojisAdd(guildID string, emojis []*Emoji) error {
	for _, e := range emojis {
		if err := s.EmojiAdd(guildID, e); err != nil {
			return err
		}
	}
	return nil
}
809674
func ValidDataUnitSymbol(u string) bool {
	for _, d := range DataUnits {
		if u == d {
			return true
		}
	}
	return false
}
708422
func parsePrefixAsIdd(iddPattern *regexp.Regexp, number *builder.Builder) bool {
	numStr := number.String()
	ind := iddPattern.FindStringIndex(numStr)
	if len(ind) == 0 || ind[0] != 0 {
		return false
	}
	matchEnd := ind[1] // ind is a two element slice
	// Only strip this if the first digit after the match is not
	// a 0, since country calling codes cannot begin with 0.
	find := CAPTURING_DIGIT_PATTERN.FindAllString(numStr[matchEnd:], -1)
	if len(find) > 0 {
		if NormalizeDigitsOnly(find[0]) == "0" {
			return false
		}
	}

	numBytes := []byte(numStr)
	number.ResetWith(numBytes[matchEnd:])
	return true
}
1016874
func padID(id string) string {
	expectedLen := 0
	if len(id) < 16 {
		expectedLen = 16
	} else if len(id) > 16 && len(id) < 32 {
		expectedLen = 32
	} else {
		return id
	}

	return pads[expectedLen-len(id)] + id
}
611655
func ParseID(s string) (ID, error) {
	i, err := strconv.ParseUint(s, 16, 64)
	if err != nil {
		return 0, err
	}
	return ID(i), nil
}
1188282
func formatVirtualDiskUUID(uuid string) string {
	uuidwithNoSpace := strings.Replace(uuid, " ", "", -1)
	uuidWithNoHypens := strings.Replace(uuidwithNoSpace, "-", "", -1)
	return strings.ToLower(uuidWithNoHypens)
}