コード例 #1
0
ファイル: recurring_test.go プロジェクト: keep94/tasks
func TestOnTheHour(t *testing.T) {
	firstTime := time.Date(2013, 9, 12, 18, 0, 0, 0, time.Local)
	r := recurring.Until(recurring.OnTheHour(), firstTime.Add(3*time.Hour))
	verifyTimes(
		t,
		r.ForTime(kNow),
		firstTime,
		firstTime.Add(time.Hour),
		firstTime.Add(2*time.Hour))
}
コード例 #2
0
ファイル: recurring_test.go プロジェクト: keep94/tasks
func TestStartAtUntilNested(t *testing.T) {
	hourly := recurring.OnTheHour()
	thanksgiving9 := time.Date(2013, 11, 28, 9, 0, 0, 0, time.Local)
	thanksgiving10 := time.Date(2013, 11, 28, 10, 0, 0, 0, time.Local)
	thanksgiving12 := time.Date(2013, 11, 28, 12, 0, 0, 0, time.Local)
	thanksgiving13 := time.Date(2013, 11, 28, 13, 0, 0, 0, time.Local)
	thanksgiving10and11 := recurring.Until(
		recurring.StartAt(
			recurring.Until(
				recurring.StartAt(hourly, thanksgiving10),
				thanksgiving13),
			thanksgiving9),
		thanksgiving12)
	verifyTimes(
		t,
		thanksgiving10and11.ForTime(kNow),
		time.Date(2013, 11, 28, 10, 0, 0, 0, time.Local),
		time.Date(2013, 11, 28, 11, 0, 0, 0, time.Local))
	thanksgiving10and11again := recurring.Until(
		recurring.StartAt(
			recurring.Until(
				recurring.StartAt(hourly, thanksgiving9),
				thanksgiving12),
			thanksgiving10),
		thanksgiving13)
	verifyTimes(
		t,
		thanksgiving10and11again.ForTime(kNow),
		time.Date(2013, 11, 28, 10, 0, 0, 0, time.Local),
		time.Date(2013, 11, 28, 11, 0, 0, 0, time.Local))
	thanksgiving9On := recurring.StartAt(hourly, thanksgiving9)
	verifyTimes(
		t,
		functional.Slice(thanksgiving9On.ForTime(kNow), 0, 3),
		time.Date(2013, 11, 28, 9, 0, 0, 0, time.Local),
		time.Date(2013, 11, 28, 10, 0, 0, 0, time.Local),
		time.Date(2013, 11, 28, 11, 0, 0, 0, time.Local))
}
コード例 #3
0
ファイル: recurring_test.go プロジェクト: keep94/tasks
func TestStartAtUntil(t *testing.T) {
	hourly := recurring.OnTheHour()
	thanksgiving10 := time.Date(2013, 11, 28, 10, 0, 0, 0, time.Local)
	thanksgiving10and11 := recurring.Until(
		recurring.StartAt(hourly, thanksgiving10),
		thanksgiving10.Add(time.Hour*2))
	verifyTimes(
		t,
		thanksgiving10and11.ForTime(kNow),
		time.Date(2013, 11, 28, 10, 0, 0, 0, time.Local),
		time.Date(2013, 11, 28, 11, 0, 0, 0, time.Local))
	verifyTimes(
		t,
		thanksgiving10and11.ForTime(thanksgiving10),
		time.Date(2013, 11, 28, 11, 0, 0, 0, time.Local))
	thanksgiving11and12 := recurring.Until(
		recurring.StartAt(hourly, thanksgiving10.Add(time.Nanosecond)),
		thanksgiving10.Add(time.Nanosecond).Add(time.Hour*2))
	verifyTimes(
		t,
		thanksgiving11and12.ForTime(kNow),
		time.Date(2013, 11, 28, 11, 0, 0, 0, time.Local),
		time.Date(2013, 11, 28, 12, 0, 0, 0, time.Local))
}