// formatYyyyMmDd is a convenience function that formats a given Time according to
// the DateformatYyyyMmDd const
343827
func formatYyyyMmDd(indate time.Time) string {
	if indate.IsZero() {
		return ""
	}
	return indate.Format(dateformatYyyyMmDd)
}
990643
func (dt DateTime) Format(layout string) string {
	return dt.t.Format(layout)
}
851835
func (c Calendar) formatDateTimeComponentYearLength2Plus(year int) string {
	yearShort := year % 100

	if yearShort < 10 {
		return fmt.Sprintf("0%d", yearShort)
	}

	return fmt.Sprintf("%d", yearShort)
}
75214
func (d Date) Format(layout string) string {
	return d.t.Format(layout)
}
1102311
func ioOutputFormatDay(ld *LineData, b *bytes.Buffer) error {
	_, err := b.WriteString(fmt.Sprintf("%02d", ld.TimeStamp.Day()))
	return err
}
546534
func formatID(base string, formatted string) string {
	if formatted == "" {
		return formatted
	}
	switch {
	case base == "id":
		// id -> ID
		return "ID"
	case strings.HasPrefix(base, "id_"):
		// id_some -> IDSome
		return "ID" + formatted[2:]
	case strings.HasSuffix(base, "_id"):
		// some_id -> SomeID
		return formatted[:len(formatted)-2] + "ID"
	case strings.HasSuffix(base, "_ids"):
		// some_ids -> SomeIDs
		return formatted[:len(formatted)-3] + "IDs"
	}
	return formatted
}
1246263
func (t *Translator) FormatDateTime(format int, datetime time.Time) (string, error) {
	pattern := ""
	switch format {
	case DateFormatFull:
		pattern = t.rules.DateTime.Formats.Date.Full
	case DateFormatLong:
		pattern = t.rules.DateTime.Formats.Date.Long
	case DateFormatMedium:
		pattern = t.rules.DateTime.Formats.Date.Medium
	case DateFormatShort:
		pattern = t.rules.DateTime.Formats.Date.Short
	case TimeFormatFull:
		pattern = t.rules.DateTime.Formats.Time.Full
	case TimeFormatLong:
		pattern = t.rules.DateTime.Formats.Time.Long
	case TimeFormatMedium:
		pattern = t.rules.DateTime.Formats.Time.Medium
	case TimeFormatShort:
		pattern = t.rules.DateTime.Formats.Time.Short
	case DateTimeFormatFull:
		datePattern := strings.Trim(t.rules.DateTime.Formats.Date.Full, " ,")
		timePattern := strings.Trim(t.rules.DateTime.Formats.Time.Full, " ,")
		pattern = getDateTimePattern(t.rules.DateTime.Formats.DateTime.Full, datePattern, timePattern)
	case DateTimeFormatLong:
		datePattern := strings.Trim(t.rules.DateTime.Formats.Date.Long, " ,")
		timePattern := strings.Trim(t.rules.DateTime.Formats.Time.Long, " ,")
		pattern = getDateTimePattern(t.rules.DateTime.Formats.DateTime.Long, datePattern, timePattern)
	case DateTimeFormatMedium:
		datePattern := strings.Trim(t.rules.DateTime.Formats.Date.Medium, " ,")
		timePattern := strings.Trim(t.rules.DateTime.Formats.Time.Medium, " ,")
		pattern = getDateTimePattern(t.rules.DateTime.Formats.DateTime.Medium, datePattern, timePattern)
	case DateTimeFormatShort:
		datePattern := strings.Trim(t.rules.DateTime.Formats.Date.Short, " ,")
		timePattern := strings.Trim(t.rules.DateTime.Formats.Time.Short, " ,")
		pattern = getDateTimePattern(t.rules.DateTime.Formats.DateTime.Short, datePattern, timePattern)
	default:
		return "", translatorError{message: "unknown datetime format" + pattern[0:1]}
	}

	parsed, err := t.parseDateTimeFormat(pattern)
	if err != nil {
		return "", err
	}

	return t.formatDateTime(datetime, parsed)
}
149057
func (m *MultiFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) {
	m.mutex.RLock()
	for i := range m.formatters {
		m.formatters[i].Format(w, entry, fields)
	}
	m.mutex.RUnlock()
}
627837
func FormatByte(args ...interface{}) string {
	sizes := [...]string{"YB", "ZB", "EB", "PB", "TB", "GB", "MB", "KB", "B"}
	var (
		total     int     = len(sizes)
		size      float64 = 0
		precision int     = 0
	)
	ln := len(args)
	if ln > 0 {
		switch args[0].(type) {
		case float64:
			size = args[0].(float64)
		case float32:
			size = float64(args[0].(float32))
		case int64:
			size = float64(args[0].(int64))
		case int32:
			size = float64(args[0].(int32))
		case int:
			size = float64(args[0].(int))
		case uint64:
			size = float64(args[0].(uint64))
		case uint32:
			size = float64(args[0].(uint32))
		case uint:
			size = float64(args[0].(uint))
		case string:
			i, _ := strconv.Atoi(args[0].(string))
			size = float64(i)
		default:
			fmt.Printf("FormatByte error: first param (%#v) invalid.\n", args[0])
		}
	}
	if ln > 1 {
		switch args[1].(type) {
		case int:
			precision = args[1].(int)
		case int64:
			precision = int(args[1].(int64))
		case int32:
			precision = int(args[1].(int32))
		case uint:
			precision = int(args[1].(uint))
		case uint64:
			precision = int(args[1].(uint64))
		case uint32:
			precision = int(args[1].(uint32))
		default:
			fmt.Printf("FormatByte error: second param (%#v) invalid.\n", args[1])
		}
	}
	for total--; total > 0 && size > 1024.0; total-- {
		size /= 1024.0
	}
	return fmt.Sprintf("%.*f%s", precision, size, sizes[total])
}
1347188
func (f *PoliteJSONFormatter) Format(calldepth int, r *logging.Record, w io.Writer) error {
	entry := make(map[string]interface{})
	entry["id"] = r.Id
	entry["level"] = r.Level
	entry["time"] = r.Time
	entry["module"] = r.Module
	entry["message"] = r.Message()
	err := json.NewEncoder(w).Encode(entry)
	if err != nil {
		return err
	}

	w.Write([]byte{'\n'})
	return nil
}
842606
func (cfg Config) Format(t time.Time) string {
	return cfg.FormatReference(t, time.Now())
}
1369597
func formatLockTime(lockTime uint32) string {
	// The lock time field of a transaction is either a block height at
	// which the transaction is finalized or a timestamp depending on if the
	// value is before the lockTimeThreshold.  When it is under the
	// threshold it is a block height.
	if lockTime < txscript.LockTimeThreshold {
		return fmt.Sprintf("height %d", lockTime)
	}

	return time.Unix(int64(lockTime), 0).String()
}
532609
func (ha *HourAngle) Format(f fmt.State, c rune) {
	s := &state{
		State:  f,
		verb:   c,
		hrDeg:  ha.Hour(),
		caller: fsHourAngle,
		sym:    ha.Sym,
	}
	ha.Err = s.writeFormatted()
}
409503
func (t *Translator) formatDateTimeComponentYear(datetime time.Time, length int) (string, error) {
	year := datetime.Year()
	switch length {
	case datetimeFormatLength1Plus:
		return t.formatDateTimeComponentYearLengthWide(year), nil
	case datetimeFormatLength2Plus:
		return t.formatDateTimeComponentYearLength2Plus(year), nil
	case datetimeFormatLengthWide:
		return t.formatDateTimeComponentYearLengthWide(year), nil
	}

	return "", translatorError{message: fmt.Sprintf("unsupported year length: %d", length)}
}
780029
func (u UUID) Format(style Style) string {
	switch style {
	case StyleWithoutDash:
		return fmt.Sprintf("%x", u[:])
	//case StyleStandard:
	default:
		return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x", u[:4], u[4:6], u[6:8], u[8:10], u[10:])
	}
}
1175149
func formatBytes(i int64) (result string) {
	switch {
	case i >= TiB:
		result = fmt.Sprintf("%.02f TiB", float64(i)/TiB)
	case i >= GiB:
		result = fmt.Sprintf("%.02f GiB", float64(i)/GiB)
	case i >= MiB:
		result = fmt.Sprintf("%.02f MiB", float64(i)/MiB)
	case i >= KiB:
		result = fmt.Sprintf("%.02f KiB", float64(i)/KiB)
	default:
		result = fmt.Sprintf("%d B", i)
	}
	return
}
124081
func (t *Translator) formatDateTimeComponentPeriodWide(hour int) string {
	if hour < 12 {
		return t.rules.DateTime.FormatNames.Periods.Wide.AM
	}

	return t.rules.DateTime.FormatNames.Periods.Wide.PM
}