// Days returns the number of days in the range
// zero will be returned for infinity TODO or -1
433499
func (term Range) Days() int {
	// Set timezones both to UTC to avoid issues of daylight savings
	if term.Start.IsZero() || term.End.IsZero() {
		return 0
	}
	// A single day range includes itself
	return int(term.End.UTC().Sub(term.Start.UTC()).Hours()/24) + 1
}
220631
func (c *Carbon) DiffInWeekendDays(carb *Carbon, abs bool) int64 {
	f := func(t *Carbon) bool {
		return t.IsWeekend()
	}

	return c.DiffFiltered(dayDuration, f, carb, abs)
}
661438
func (m DayOfMonthMapper) ID(ti ...interface{}) (rowIDs []int64, err error) {
	t := ti[0].(time.Time)
	return []int64{int64(t.Day())}, nil
}
536245
func OrdinalWeekday(i int, w Weekday) Intersection {
	return Intersection{Week(i), w}
}
8044
func (c *Carbon) StartOfDay() *Carbon {
	return create(c.Year(), c.Month(), c.Day(), 0, 0, 0, 0, c.Location())
}
80040
func TimeFromDays(num int64) Time {
	if num < 0 {
		return Time{
			Time: FromDate(0, 0, 0, 0, 0, 0, 0),
			Type: mysql.TypeDate,
			Fsp:  0,
		}
	}
	year, month, day := getDateFromDaynr(uint(num))

	return Time{
		Time: FromDate(int(year), int(month), int(day), 0, 0, 0, 0),
		Type: mysql.TypeDate,
		Fsp:  0,
	}
}
210023
func (d DateTime) DayOfMonth(v reflect.Value) (interface{}, error) {
	return d.dayOfMonth(), nil
}
988827
func (t Term) TimeOfDay(args ...interface{}) Term {
	return constructMethodTerm(t, "TimeOfDay", p.Term_TIME_OF_DAY, args, map[string]interface{}{})
}
618324
func (dt DateTime) Date() (year int, month time.Month, day int) {
	return dt.t.Date()
}
1105229
func calcWeekday(daynr int, sundayFirstDayOfWeek bool) int {
	daynr += 5
	if sundayFirstDayOfWeek {
		daynr++
	}
	return daynr % 7
}
645820
func (s *RetentionPeriod) SetNumberOfDays(v int64) *RetentionPeriod {
	s.NumberOfDays = &v
	return s
}
516197
func (j *Job) Day() *Job {
	if j.schedule != nil {
		j.err = errors.New("bad function chaining")
	}
	j.schedule = daily{}
	return j
}
676490
func (c *Carbon) DiffInDays(carb *Carbon, abs bool) int64 {
	if carb == nil {
		carb = nowIn(c.Location())
	}
	return c.DiffInHours(carb, abs) / hoursPerDay
}
498678
func MonthDays(year, month int) int {
	switch month {
	case 1, 3, 5, 7, 8, 10, 12:
		return 31
	case 4, 6, 9, 11:
		return 30
	case 2:
		if IsLeapYear(year) {
			return 29
		}
		return 28
	default:
		panic(fmt.Sprintf("Illegal month:%d", month))
	}
}
968619
func (j *Job) Day() (job *Job) {
	if j.interval != 1 {
		panic("")
	}
	job = j.Days()
	return
}
1323402
func (c *Client) Deletes(year, month, day int) (map[int]*models.DeleteOp, error) {
	var err error
	uri := fmt.Sprintf(deletesURL, year, month, day)

	data, err := httpGet(geonamesURL + uri)
	if err != nil {
		return nil, err
	}

	result := make(map[int]*models.DeleteOp)
	parse(data, 0, func(raw [][]byte) bool {
		if len(raw) != 3 {
			return true
		}
		geonameID, err := strconv.Atoi(string(raw[0]))
		if err != nil {
			log.Printf("while converting raw deletion %s geoname id: %s", string(raw[0]), err.Error())
			log.Println(string(raw[0]))
			return true
		}

		result[geonameID] = &models.DeleteOp{
			Name:    string(raw[1]),
			Comment: string(raw[2])}
		return true
	})

	return result, nil
}
423135
func (f *ForecastWeatherData) DailyByCoordinates(location *Coordinates, days int) error {
	response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("lat=%f&lon=%f", location.Latitude, location.Longitude), f.Unit, f.Lang, days))
	if err != nil {
		return err
	}
	defer response.Body.Close()

	return f.ForecastWeatherJson.Decode(response.Body)
}