Esempio n. 1
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}
}
Esempio n. 2
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)
}
Esempio n. 3
0
// AddPeriod returns the date corresponding to adding the given period. If the
// period's fields are be negative, this results in an earlier date. Any time
// component is ignored.
//
// See the description for AddDate.
func (d Date) AddPeriod(period period.Period) Date {
	return d.AddDate(period.Years(), period.Months(), period.Days())
}