示例#1
0
/*
Returns true if the received time result inside the interval
*/
func (i *RateInterval) Contains(t time.Time, endTime bool) bool {
	if endTime {
		if utils.TimeIs0h(t) { // back one second to 23:59:59
			t = t.Add(-1 * time.Second)
		}
	}
	return i.Timing.IsActiveAt(t)
}
示例#2
0
// Splits the given timespan on activation period's activation time.
func (ts *TimeSpan) SplitByDay() (newTs *TimeSpan) {
	if ts.TimeStart.Day() == ts.TimeEnd.Day() || utils.TimeIs0h(ts.TimeEnd) {
		return
	}

	splitDate := ts.TimeStart.AddDate(0, 0, 1)
	splitDate = time.Date(splitDate.Year(), splitDate.Month(), splitDate.Day(), 0, 0, 0, 0, splitDate.Location())
	newTs = &TimeSpan{
		TimeStart: splitDate,
		TimeEnd:   ts.TimeEnd,
	}
	newTs.copyRatingInfo(ts)
	newTs.DurationIndex = ts.DurationIndex
	ts.TimeEnd = splitDate
	ts.SetNewDurationIndex(newTs)
	return
}
示例#3
0
// Splits the given timespan on activation period's activation time.
func (ts *TimeSpan) SplitByDay() (newTs *TimeSpan) {
	if ts.TimeStart.Day() == ts.TimeEnd.Day() || utils.TimeIs0h(ts.TimeEnd) {
		return
	}

	splitDate := ts.TimeStart.AddDate(0, 0, 1)
	splitDate = time.Date(splitDate.Year(), splitDate.Month(), splitDate.Day(), 0, 0, 0, 0, splitDate.Location())
	newTs = &TimeSpan{
		TimeStart: splitDate,
		TimeEnd:   ts.TimeEnd,
	}
	newTs.copyRatingInfo(ts)
	newTs.DurationIndex = ts.DurationIndex
	ts.TimeEnd = splitDate
	ts.SetNewDurationIndex(newTs)
	// Logger.Debug(fmt.Sprintf("RP SPLITTING: %+v %+v", ts, newTs))
	return
}