From efbad7a6ef8ad8ca54a97648d2e21c096fd093a0 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Thu, 2 Feb 2012 22:55:30 +0200 Subject: [PATCH] good night --- timespans/calldesc_test.go | 2 +- timespans/interval_test.go | 4 ++-- timespans/intervals.go | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/timespans/calldesc_test.go b/timespans/calldesc_test.go index 7c8c82af9..5d30af7df 100644 --- a/timespans/calldesc_test.go +++ b/timespans/calldesc_test.go @@ -20,7 +20,7 @@ func TestSplitSpans(t *testing.T){ intervals := cd.getActiveIntervals() timespans := cd.splitInTimeSpans(intervals) if len(timespans) != 2 { - t.Error("Wrong number of timespans!") + t.Error("Wrong number of timespans: ", len(timespans)) } } diff --git a/timespans/interval_test.go b/timespans/interval_test.go index f7035e156..763a0df87 100644 --- a/timespans/interval_test.go +++ b/timespans/interval_test.go @@ -111,8 +111,8 @@ func TestEverything(t *testing.T){ EndTime: "15:00:00"} d := time.Date(2012, time.February, 1, 14, 30, 1, 0, time.UTC) d1 := time.Date(2012, time.February, 1, 14, 29, 1, 0, time.UTC) - d2 := time.Date(2012, time.February, 1, 14, 59, 59, 0, time.UTC) - d3 := time.Date(2012, time.February, 1, 15, 0, 0, 0, time.UTC) + d2 := time.Date(2012, time.February, 1, 15, 00, 00, 0, time.UTC) + d3 := time.Date(2012, time.February, 1, 15, 0, 1, 0, time.UTC) if !i.Contains(d) { t.Errorf("Date %v shoud be in interval %v", d, i) } diff --git a/timespans/intervals.go b/timespans/intervals.go index 573200a76..a5a9ce389 100644 --- a/timespans/intervals.go +++ b/timespans/intervals.go @@ -48,7 +48,7 @@ func (i *Interval) Contains(t time.Time) bool { // if the hour is before or is the same hour but the minute is before if t.Hour() < sh || (t.Hour() == sh && t.Minute() < sm) || - (t.Hour() == sh && t.Minute() == sm && t.Second() <= ss) { + (t.Hour() == sh && t.Minute() == sm && t.Second() < ss) { return false } } @@ -61,7 +61,7 @@ func (i *Interval) Contains(t time.Time) bool { // if the hour is after or is the same hour but the minute is after if t.Hour() > eh || (t.Hour() == eh && t.Minute() > em) || - (t.Hour() == eh && t.Minute() == em && t.Second() >= es) { + (t.Hour() == eh && t.Minute() == em && t.Second() > es) { return false } } @@ -78,8 +78,8 @@ func (i *Interval) ContainsSpan(t *TimeSpan) bool { /* Returns true if the timespan is fully enclosed in the interval */ -func (i *Interval) ContainsFullSpan(t *TimeSpan) bool { - return i.Contains(t.TimeStart) && i.Contains(t.TimeEnd) +func (i *Interval) ContainsFullSpan(ts *TimeSpan) bool { + return i.Contains(ts.TimeStart) && i.Contains(ts.TimeEnd) } /* @@ -130,15 +130,15 @@ func (i *Interval) Split(ts *TimeSpan) (nts *TimeSpan) { return } // if the span is enclosed in the interval try to set as new interval and return nil - if i.ContainsFullSpan(ts){ + if i.ContainsFullSpan(ts){ ts.SetInterval(i) return } - // if only the start time is in the interval splitt he interval + // if only the start time is in the interval split he interval if i.Contains(ts.TimeStart){ splitTime := i.getRightMargin(ts.TimeStart) ts.SetInterval(i) - if splitTime == ts.TimeStart { + if splitTime == ts.TimeEnd { return } oldTimeEnd := ts.TimeEnd @@ -150,7 +150,7 @@ func (i *Interval) Split(ts *TimeSpan) (nts *TimeSpan) { // if only the end time is in the interval split the interval if i.Contains(ts.TimeEnd){ splitTime := i.getLeftMargin(ts.TimeEnd) - if splitTime == ts.TimeStart { + if splitTime == ts.TimeEnd { ts.SetInterval(i) return }