// formatDateTimeComponentQuarter renders a calendar quarter component - this
// is calendar quarters and not fiscal quarters.
//  - Q1: Jan-Mar
//  - Q2: Apr-Jun
//  - Q3: Jul-Sep
//  - Q4: Oct-Dec
// TODO: not yet implemented
508778
func (c Calendar) formatDateTimeComponentQuarter(datetime time.Time, length int) (string, error) {
	return "", nil
}
179968
func (c Calendar) formatDateTimeComponentDayOfWeekNarrow(dayOfWeek time.Weekday) string {
	switch dayOfWeek {
	case time.Sunday:
		return c.FormatNames.Days.Narrow.Sun
	case time.Monday:
		return c.FormatNames.Days.Narrow.Mon
	case time.Tuesday:
		return c.FormatNames.Days.Narrow.Tue
	case time.Wednesday:
		return c.FormatNames.Days.Narrow.Wed
	case time.Thursday:
		return c.FormatNames.Days.Narrow.Thu
	case time.Friday:
		return c.FormatNames.Days.Narrow.Fri
	case time.Saturday:
		return c.FormatNames.Days.Narrow.Sat
	}

	return ""
}
1286777
func formatGroupingQuery(mainQuery, group, column string) string {
	if group == "all" {
		return fmt.Sprintf(mainQuery, column)
	}
	subQuery := fmt.Sprintf("date_trunc('%s', %s)", group, column)
	return fmt.Sprintf(mainQuery, subQuery)
}
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
}
526688
func QuarterDuration(dt time.Time) time.Duration {
	start := QuarterStart(dt)
	end := NextQuarter(start)
	return end.Sub(start)
}
295312
func (c Calendar) formatDateTimeComponentDayOfWeek(datetime time.Time, length int) (string, error) {
	switch length {
	case datetimeFormatLength1Plus:
		return c.formatDateTimeComponentDayOfWeekWide(datetime.Weekday()), nil
	case datetimeFormatLength2Plus:
		return c.formatDateTimeComponentDayOfWeekShort(datetime.Weekday()), nil
	case datetimeFormatLengthAbbreviated:
		return c.formatDateTimeComponentDayOfWeekAbbreviated(datetime.Weekday()), nil
	case datetimeFormatLengthWide:
		return c.formatDateTimeComponentDayOfWeekWide(datetime.Weekday()), nil
	case datetimeFormatLengthNarrow:
		return c.formatDateTimeComponentDayOfWeekNarrow(datetime.Weekday()), nil
	}

	return "", fmt.Errorf("unsupported year day-of-week: %d", length)
}
972995
func (c Calendar) formatDateTimeComponentHour12(datetime time.Time, length int) (string, error) {
	hour := datetime.Hour()
	if hour > 12 {
		hour = hour - 12
	}

	switch length {
	case datetimeFormatLength1Plus:
		return fmt.Sprintf("%d", hour), nil
	case datetimeFormatLength2Plus:
		if hour < 10 {
			return fmt.Sprintf("0%d", hour), nil
		}
		return fmt.Sprintf("%d", hour), nil
	}

	return "", fmt.Errorf("unsupported hour-12: %d", length)
}
837143
func (c *Carbon) StartOfQuarter() *Carbon {
	month := time.Month((c.Quarter()-1)*monthsPerQuarter + 1)

	return create(c.Year(), time.Month(month), 1, 0, 0, 0, 0, c.Location())
}
1265084
func splitDateTime(format string) (seps []string, fracStr string) {
	index := GetFracIndex(format)
	if index > 0 {
		fracStr = format[index+1:]
		format = format[:index]
	}

	seps = ParseDateFormat(format)
	return
}
905923
func QuarterEnd(dt time.Time) time.Time {
	qs := QuarterStart(dt.UTC())
	qn := TimeDt6AddNMonths(qs, 3)
	return time.Date(qn.Year(), qn.Month(), 0, 23, 59, 59, 0, time.UTC)
}
301160
func (k *Key) RangeTimeFormat(format string, defaultVal, min, max time.Time) time.Time {
	val := k.MustTimeFormat(format)
	if val.Unix() < min.Unix() || val.Unix() > max.Unix() {
		return defaultVal
	}
	return val
}
897211
func (c Calendar) formatDateTimeComponentMonthNarrow(month int) string {
	switch month {
	case 1:
		return c.FormatNames.Months.Narrow.Jan
	case 2:
		return c.FormatNames.Months.Narrow.Feb
	case 3:
		return c.FormatNames.Months.Narrow.Mar
	case 4:
		return c.FormatNames.Months.Narrow.Apr
	case 5:
		return c.FormatNames.Months.Narrow.May
	case 6:
		return c.FormatNames.Months.Narrow.Jun
	case 7:
		return c.FormatNames.Months.Narrow.Jul
	case 8:
		return c.FormatNames.Months.Narrow.Aug
	case 9:
		return c.FormatNames.Months.Narrow.Sep
	case 10:
		return c.FormatNames.Months.Narrow.Oct
	case 11:
		return c.FormatNames.Months.Narrow.Nov
	case 12:
		return c.FormatNames.Months.Narrow.Dec
	}

	return ""
}
1274080
func (q *DateRangeQuery) DateTimeParser(parser string) *DateRangeQuery {
	q.options["datetime_parser"] = parser
	return q
}
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)}
}
664407
func FormatDateTimeField(key string, val time.Time) (string, string) {
	return key + ";VALUE=DATE-TIME", val.Format("20060102T150405")
}
775796
func (c *AppversionListCall) DateEnd(dateEnd int64) *AppversionListCall {
	c.urlParams_.Set("dateEnd", fmt.Sprint(dateEnd))
	return c
}
668101
func PercentValueFormatter(v interface{}) string {
	if typed, isTyped := v.(float64); isTyped {
		return FloatValueFormatterWithFormat(typed*100.0, DefaultPercentValueFormat)
	}
	return ""
}