// StartOfDay returns the time at 00:00:00 of the same day
8044
func (c *Carbon) StartOfDay() *Carbon {
	return create(c.Year(), c.Month(), c.Day(), 0, 0, 0, 0, c.Location())
}
89950
func StartTime(t time.Time) func(*sonyflake.Settings) {
	return func(s *sonyflake.Settings) {
		s.StartTime = t
	}
}
976446
func parseStart(start string) (*periodicStart, error) {
	ps := &periodicStart{}
	ps.dayOfWeek = -1
	f := strings.Fields(start)

	switch len(f) {
	case 1: // no day provided
	case 2:
		if dow, ok := weekdays[strings.ToLower(f[0])]; ok {
			ps.dayOfWeek = dow
		} else {
			return nil, fmt.Errorf("invalid day of week %q", f[0])
		}
		// shift
		f = f[1:]
	default:
		return nil, fmt.Errorf("wrong number of fields")
	}

	n, err := fmt.Sscanf(f[0], "%d:%d", &ps.hourOfDay, &ps.minuteOfHour)

	// check Sscanf failure
	if n != 2 || err != nil {
		return nil, fmt.Errorf("invalid time of day %q: %v", f[0], err)
	}

	// check hour range
	if ps.hourOfDay < 0 || ps.hourOfDay > 23 {
		return nil, fmt.Errorf("invalid time of day %q: hour must be >= 0 and <= 23", f[0])
	}

	// check minute range
	if ps.minuteOfHour < 0 || ps.minuteOfHour > 59 {
		return nil, fmt.Errorf("invalid time of day %q: minute must be >= 0 and <= 59", f[0])
	}

	return ps, nil
}
317830
func dayOfMonthWithSuffix(t *mysqlTime, input string, ctx map[string]int) (string, bool) {
	month, remain := parseOrdinalNumbers(input)
	if month >= 0 {
		t.month = uint8(month)
		return remain, true
	}
	return input, false
}
1022818
func MarshalTimeOfDayTz(v TimeOfDay) (string, error) {
	d := int64(v.FromMidnight / time.Second)
	hour := d / 3600
	d = d % 3600
	minute := d / 60
	second := d % 60

	tz := ""
	if v.HasOffset {
		if v.Offset == 0 {
			tz = "Z"
		} else {
			offsetMins := v.Offset / 60
			sign := '+'
			if offsetMins < 1 {
				offsetMins = -offsetMins
				sign = '-'
			}
			tz = fmt.Sprintf("%c%02d:%02d", sign, offsetMins/60, offsetMins%60)
		}
	}

	return fmt.Sprintf("%02d:%02d:%02d%s", hour, minute, second, tz), nil
}
988827
func (t Term) TimeOfDay(args ...interface{}) Term {
	return constructMethodTerm(t, "TimeOfDay", p.Term_TIME_OF_DAY, args, map[string]interface{}{})
}
700557
func (s *DescribeAlarmHistoryInput) SetStartDate(v time.Time) *DescribeAlarmHistoryInput {
	s.StartDate = &v
	return s
}
528956
func (s *DescribeMaintenanceStartTimeOutput) SetDayOfWeek(v int64) *DescribeMaintenanceStartTimeOutput {
	s.DayOfWeek = &v
	return s
}
1212211
func isSameDay(wkd time.Weekday, dow dayofweek.DayOfWeek) bool {
	switch dow {
	case dayofweek.DayOfWeek_DAY_OF_WEEK_UNSPECIFIED:
		return false
	case dayofweek.DayOfWeek_SUNDAY:
		// time.Weekday has Sunday == 0, dayofweek.DayOfWeek has Sunday == 7.
		return wkd == time.Sunday
	default:
		// For all other values, time.Weekday == dayofweek.DayOfWeek.
		return int(wkd) == int(dow)
	}
}
127749
func (c *Carbon) FirstOfMonth(wd time.Weekday) *Carbon {
	d := c.StartOfMonth()
	if d.Weekday() != wd {
		return d.Next(wd)
	}

	return d
}
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 ""
}
940209
func (c *Carbon) StartOfYear() *Carbon {
	return create(c.Year(), time.January, 1, 0, 0, 0, 0, c.Location())
}
1056320
func (c *Carbon) LastOfQuarter(wd time.Weekday) *Carbon {
	d := c.EndOfQuarter()
	if d.Weekday() != wd {
		return d.Previous(wd)
	}

	return d.StartOfDay()
}
1148949
func (pc *Periodic) cmpHourOfDay(ref time.Time) time.Duration {
	pStart := pc.shiftTimeByDays(ref, 0)
	return ref.Sub(pStart)
}
292737
func (s *DescribeScheduledAuditOutput) SetDayOfWeek(v string) *DescribeScheduledAuditOutput {
	s.DayOfWeek = &v
	return s
}
404768
func (c *Carbon) StartOfDecade() *Carbon {
	year := c.Year() - c.Year()%yearsPerDecade

	return create(year, time.January, 1, 0, 0, 0, 0, c.Location())
}
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())
}