+ # Disallow backward intervals. As a special case, an etime of 0
+ # should roll to the last second of the week.
+ $self->etime(7*24*60*60) if $self->etime == 0;
+ return "end of interval is before start" if ($self->etime < $self->stime);
+
+ # Detect overlap between intervals within the same rate_time.
+ # Since intervals are added one at a time, we only need to look
+ # for an existing interval that contains one of the endpoints of
+ # this one or that is completely inside this one.
+ my $overlap = $self->rate_time->contains($self->stime + 1) ||
+ $self->rate_time->contains($self->etime - 1) ||
+ first { $self->stime <= $_->stime && $self->etime >= $_->etime }
+ ( $self->rate_time->intervals );
+ return "interval overlap: (".join('-',$self->description).') with ('.
+ join('-',$overlap->description).')' if $overlap;