[Evolution] time_add_day() problem



I think there may be a bug in the time_add_day() function (in
evolution/calendar/cal-util/timeutil.c).

I've been using it to calculate the start of each day for the calendar
views. But on the day the clocks go forward for daylight saving time
it returns 11pm for the start of the next day.

This code confuses me a bit:

        if (dst_flag > tm->tm_isdst){
                tm->tm_hour++;
                new_time += 3600;
        } else if (dst_flag < tm->tm_isdst){
                tm->tm_hour--;
                new_time -= 3600;
        }

This seems to say that if the dst flag has changed, then the new time_t
has to be adjusted.

But won't mktime() handle it correctly, just by adding on to tm_tmmday ?

The only problem I can see is if clocks go forward and the hour + minute
that you wanted doesn't really exist. (Also, when clocks go backward there
may be 2 different time_t values representing the same hour + minute - one
with DST and one without.)

Damon





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]