func (s Span) Intersection(r Span) (Span, bool) {
	if !s.Overlaps(r) {
		return Span{}, false
	}
	return Span{
		start: tmax(s.start, r.start),
		end:   tmin(s.end, r.end),
	}, true
}
Intersection returns both a span corresponding to the non-zero overlap of
s and r and a bool indicating whether such an overlap existed.
If s and r do not overlap, a zero span is returned with false.
package timespan
import (
	"time"
)
type Span struct {
	start, end time.Time
}
func New(t time.Time, d time.Duration) Span {
	start := t
	end := t.Add(d)
	if end.Before(t) {
		start, end = end, start
	}
	return Span{
		start: start,
		end:   end,
	}
}
func (s Span) Start() time.Time {
	return s.start
}
func (s Span) End() time.Time {
	return s.end
}
func (s Span) Duration() time.Duration {
	return s.end.Sub(s.start)
}
func (s Span) After(t time.Time) bool {
	return s.start.After(t)
}
func (s Span) Before(t time.Time) bool {
	return s.end.Before(t)
}
func (s Span) Borders(r Span) bool {
	return s.start.Equal(r.end) || s.end.Equal(r.start)
}
func (s Span) ContainsTime(t time.Time) bool {
	return !(t.Before(s.start) || t.After(s.end))
}
func (s Span) Contains(r Span) bool {
	return s.ContainsTime(r.start) && s.ContainsTime(r.end)
}
func (s Span) Encompass(r Span) Span {
	return Span{
		start: tmin(s.start, r.start),
		end:   tmax(s.end, r.end),
	}
}
func (s Span) Equal(r Span) bool {
	return s.start.Equal(r.start) && s.end.Equal(r.end)
}
func (s Span) Follows(r Span) bool {
	return !s.start.Before(r.end)
}
func (s Span) Gap(r Span) Span {
	if s.Overlaps(r) {
		return Span{}
	}
	return Span{
		start: tmin(s.end, r.end),
		end:   tmax(s.start, r.start),
	}
}