Beispiel #1
0
// ExtendByPeriod extends (or reduces) the date range by moving the end date.
// A negative parameter is allowed and this may cause the range to become inverted
// (i.e. the mark date becomes the end date instead of the start date).
func (dateRange DateRange) ExtendByPeriod(period period.Period) DateRange {
	if period.IsZero() {
		return dateRange
	}
	newEnd := dateRange.End().AddPeriod(period)
	//fmt.Printf("%v, end + %v : %v -> %v", dateRange.mark, period, dateRange.End(), newEnd)
	return NewDateRange(dateRange.Start(), newEnd)
}
Beispiel #2
0
// ShiftByPeriod moves the date range by moving both the start and end dates similarly.
// A negative parameter is allowed.
func (dateRange DateRange) ShiftByPeriod(period period.Period) DateRange {
	if period.IsZero() {
		return dateRange
	}
	newMark := dateRange.mark.AddPeriod(period)
	//fmt.Printf("mark + %v : %v -> %v", period, dateRange.mark, newMark)
	return DateRange{newMark, dateRange.days}
}