Beispiel #1
0
func TestCombineZeroOrOne(t *testing.T) {
	r := intRecurring(5)
	if recurring.Combine() != recurring.Nil() {
		t.Error("Expect combining no recurrings to be nil recurring.")
	}
	if recurring.Combine(r) != r {
		t.Error("Expected combine of single recurring to be that recurring.")
	}
}
Beispiel #2
0
func TestCombine3(t *testing.T) {
	r := recurring.Combine(
		recurring.Until(recurring.AtInterval(kNow, 2*time.Hour), kNow),
		recurring.Until(
			recurring.AtInterval(kNow, 3*time.Hour), kNow.Add(9*time.Hour)))
	verifyTimes(
		t,
		r.ForTime(kNow),
		kNow.Add(3*time.Hour),
		kNow.Add(6*time.Hour))
}
Beispiel #3
0
func TestDrPepper(t *testing.T) {
	r := recurring.Until(
		recurring.Combine(
			recurring.AtTime(10, 0),
			recurring.AtTime(14, 0),
			recurring.AtTime(16, 0)),
		kNow.AddDate(0, 0, 2))
	verifyTimes(
		t,
		r.ForTime(kNow),
		time.Date(2013, 9, 13, 10, 0, 0, 0, time.Local),
		time.Date(2013, 9, 13, 14, 0, 0, 0, time.Local),
		time.Date(2013, 9, 13, 16, 0, 0, 0, time.Local),
		time.Date(2013, 9, 14, 10, 0, 0, 0, time.Local),
		time.Date(2013, 9, 14, 14, 0, 0, 0, time.Local),
		time.Date(2013, 9, 14, 16, 0, 0, 0, time.Local))
}
func ExampleCombine() {
	// Daily at 10:09, 13:05, and 17:13
	r := recurring.Combine(
		recurring.AtTime(10, 9),
		recurring.AtTime(13, 5),
		recurring.AtTime(17, 13))
	stream := r.ForTime(time.Date(2013, 10, 2, 12, 0, 0, 0, time.Local))
	layout := "Jan 2 15:04:05"
	var current time.Time
	for i := 0; i < 8; i++ {
		stream.Next(&current)
		fmt.Println(current.Format(layout))
	}
	// Output:
	// Oct 2 13:05:00
	// Oct 2 17:13:00
	// Oct 3 10:09:00
	// Oct 3 13:05:00
	// Oct 3 17:13:00
	// Oct 4 10:09:00
	// Oct 4 13:05:00
	// Oct 4 17:13:00
}
Beispiel #5
0
func TestCombine2(t *testing.T) {
	r := recurring.Combine(recurring.Nil(), recurring.Nil())
	verifyTimes(
		t,
		r.ForTime(kNow))
}