good night

This commit is contained in:
Radu Ioan Fericean
2012-02-02 22:55:30 +02:00
parent d94716fdc0
commit efbad7a6ef
3 changed files with 11 additions and 11 deletions

View File

@@ -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))
}
}

View File

@@ -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)
}

View File

@@ -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
}