Logo Search packages:      
Sourcecode: libical version File versions  Download package

struct icaltimetype icaltime_from_day_of_year ( const int  _doy,
const int  _year 
) [read]

Contructor.

Create a new time, given a day of year and a year.

Create a new time, given a day of year and a year.

Definition at line 702 of file icaltime.c.

{
    struct icaltimetype tt = icaltime_null_date();
    int is_leap;
    int month;
    int doy = _doy;
    int year = _year;

    is_leap = icaltime_is_leap_year(year);

    /* Zero and neg numbers represent days  of the previous year */
    if(doy <1){
        year--;
        is_leap = icaltime_is_leap_year(year);
        doy +=  days_in_year_passed_month[is_leap][12];
    } else if(doy > days_in_year_passed_month[is_leap][12]){
        /* Move on to the next year*/
        is_leap = icaltime_is_leap_year(year);
        doy -=  days_in_year_passed_month[is_leap][12];
        year++;
    }

    tt.year = year;

    for (month = 11; month >= 0; month--) {
      if (doy > days_in_year_passed_month[is_leap][month]) {
      tt.month = month + 1;
      tt.day = doy - days_in_year_passed_month[is_leap][month];
      break;
      }
    }

    return tt;
}


Generated by  Doxygen 1.6.0   Back to index