| Extracted from Pike v7.8 release 866 at 2018-07-18.

[Top]
Calendar
Calendar.TimeRange

# Method Calendar.TimeRange()->add()

Method add

  `TimeRange add(int n, void|TimeRange step)`

Description

  calculates the (promoted) time period n steps away; if no step is given, the step's length is of the same length as the called time period.

  It is not recommended to loop by adding the increment time period to a shorter period; this can cause faults, if the shorter time period doesn't exist in the incremented period. (Like week 53, day 31 of a month or the leap day of a year.)

  Recommended use are like this:

         // loop over the 5th of the next 10 months
         TimeRange month=Month()+1;
         TimeRange orig_day=month()->day(5);
         for (int i=0; i<10; i++)
         {
            month++;
            TimeRange day=month->place(orig_day);
            ...use day...
         }