Logo Search packages:      
Sourcecode: libical version File versions

static void icaltimezone_adjust_change ( icaltimezonechange *  tt,
int  days,
int  hours,
int  minutes,
int  seconds 
) [static]

Adds (or subtracts) a time from a icaltimezonechange. NOTE: This function is exactly the same as icaltime_adjust() except for the type of the first parameter.

Definition at line 1095 of file icaltimezone.c.

Referenced by icaltimezone_get_utc_offset().

{
    int second, minute, hour, day;
    int minutes_overflow, hours_overflow, days_overflow;
    int days_in_month;

    /* Add on the seconds. */
    second = tt->second + seconds;
    tt->second = second % 60;
    minutes_overflow = second / 60;
    if (tt->second < 0) {
      tt->second += 60;
      minutes_overflow--;
    }

    /* Add on the minutes. */
    minute = tt->minute + minutes + minutes_overflow;
    tt->minute = minute % 60;
    hours_overflow = minute / 60;
    if (tt->minute < 0) {
      tt->minute += 60;
      hours_overflow--;
    }

    /* Add on the hours. */
    hour = tt->hour + hours + hours_overflow;
    tt->hour = hour % 24;
    days_overflow = hour / 24;
    if (tt->hour < 0) {
      tt->hour += 24;
      days_overflow--;
    }

    /* Add on the days. */
    day = tt->day + days + days_overflow;
    if (day > 0) {
      for (;;) {
          days_in_month = icaltime_days_in_month (tt->month, tt->year);
          if (day <= days_in_month)
            break;

          tt->month++;
          if (tt->month >= 13) {
            tt->year++;
            tt->month = 1;
          }

          day -= days_in_month;
      }
    } else {
      while (day <= 0) {
          if (tt->month == 1) {
            tt->year--;
            tt->month = 12;
          } else {
            tt->month--;
          }

          day += icaltime_days_in_month (tt->month, tt->year);
      }
    }
    tt->day = day;
}


Generated by  Doxygen 1.6.0   Back to index