Branch: Tag:

2000-08-14

2000-08-14 12:35:59 by Mirar (Pontus Hagland) <pike@sort.mirar.org>

added ->offset_to

Rev: lib/modules/Calendar.pmod/TimeRanges.pmod:1.5

403:    else return how_many(x);    }    + //! method int offset_to(TimeRange x) + //! Calculates offset to x; this compares + //! two timeranges and gives the integer offset + //! between the two starting points. + //! + //! This is true for suitable a and b: + //! <tt>a+a->offset_to(b)==b</tt> + //! + //! By suitable means that a and b are of the same + //! type and size. This is obviously true only + //! if a+n has b as a possible result for any n. +  +  int offset_to(TimeRange x) +  { +  if (x==this_object()) return 0; +  if (x<this_object()) +  return -(x->distance(this_object())/this_object()); +  return this_object()->distance(x)/this_object(); +  } +    //! method TimeRange beginning()   //! method TimeRange end()   //! This gives back the zero-sized beginning