Re: [Evolution] latest cvs version - problems with all day events



Damon Chaplin wrote:

Guy wrote:

first of all I like the new spash screen!

I notice that now when I open a calendar, what were once daily reminders
without times (I never worked out if they were different to all day
events) now become events which span a 24hour period over 2 days.

Is this intended?

Probably not.

It may be a bug introduced by the new libical - some of the time_t
conversion functions have been changed.

icaltime_as_timet() looks broken to me (icaltime_local_utc_offset() seems
to be using the gmt-offset from the current time, which is wrong, and I
also don't think 'timezone' is reliable - I thought Eric fixed this.)

I'd feel safer if we set TZ to "UTC" and used mktime() like below
(but note that I haven't tested this, it's just an idea):

/* Always returns time in UTC */
time_t icaltime_as_timet(struct icaltimetype tt)
{
    struct tm stm;
    time_t tut;
    static char old_tz[1024];

    memset(&stm,0,sizeof( struct tm));

    stm.tm_sec = tt.second;
    stm.tm_min = tt.minute;
    stm.tm_hour = tt.hour;
    stm.tm_mday = tt.day;
    stm.tm_mon = tt.month-1;
    stm.tm_year = tt.year-1900;
    stm.tm_isdst = -1; /* prevents mktime from changing hour based on
                          daylight savings */

    if(tt.is_utc){
      /* We want to temporarily set TZ to UTC while calling mktime().
         First we save the old TZ by copying it to a static buffer. */
      tmp_old_tz = getenv ("TZ");

      old_tz[0] = 0;
      if (tmp_old_tz) {
        if (strlen (tmp_old_tz) <= 1020) {
          strcpy (old_tz, "TZ=");
          strcpy (old_tz + 3, tmp_old_tz);
        } else {
          /* Print a warning "TZ too long" or something. */
        }
      }

      /* Set to UTC. */
      putenv ("TZ=UTC");
    }

    /* Do the mktime(). */
    tut = mktime (tmp_tm);

    if(tt.is_utc){
      /* Restore the old TZ. */
      if (old_tz[0])
        putenv (old_tz);
      else
        putenv ("TZ");
    }

    return tut;
}


Damon





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