diff options
author | Miguel de Icaza <miguel@nuclecu.unam.mx> | 1998-05-16 08:52:33 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-05-16 08:52:33 +0800 |
commit | 418f8bfcb52e54cdf88ef9b10c2cd185cd116fe8 (patch) | |
tree | 7a78067e84f745f1db3fb1cfdcc015a0cb89e9bd | |
parent | 3799134926a1db309a2b46706d8a33581999f778 (diff) | |
download | gsoc2013-evolution-418f8bfcb52e54cdf88ef9b10c2cd185cd116fe8.tar gsoc2013-evolution-418f8bfcb52e54cdf88ef9b10c2cd185cd116fe8.tar.gz gsoc2013-evolution-418f8bfcb52e54cdf88ef9b10c2cd185cd116fe8.tar.bz2 gsoc2013-evolution-418f8bfcb52e54cdf88ef9b10c2cd185cd116fe8.tar.lz gsoc2013-evolution-418f8bfcb52e54cdf88ef9b10c2cd185cd116fe8.tar.xz gsoc2013-evolution-418f8bfcb52e54cdf88ef9b10c2cd185cd116fe8.tar.zst gsoc2013-evolution-418f8bfcb52e54cdf88ef9b10c2cd185cd116fe8.zip |
Bug free version of the range computation in place.
1998-05-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gnome-cal.c (mark_gtk_calendar_day): Bug free version of the
range computation in place.
* gncal-year-view.c (year_view_mark_day): Use the same new version
of the range computation here.
* calobj.c (ical_object_generate_events): Fix the begin/end
condition.
svn path=/trunk/; revision=215
-rw-r--r-- | calendar/ChangeLog | 11 | ||||
-rw-r--r-- | calendar/cal-util/calobj.c | 4 | ||||
-rw-r--r-- | calendar/calobj.c | 4 | ||||
-rw-r--r-- | calendar/gnome-cal.c | 21 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 21 | ||||
-rw-r--r-- | calendar/gui/year-view.c | 23 | ||||
-rw-r--r-- | calendar/pcs/calobj.c | 4 | ||||
-rw-r--r-- | calendar/year-view.c | 23 |
8 files changed, 63 insertions, 48 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index c842753ec2..a63dfd600c 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,14 @@ +1998-05-15 Miguel de Icaza <miguel@nuclecu.unam.mx> + + * gnome-cal.c (mark_gtk_calendar_day): Bug free version of the + range computation in place. + + * gncal-year-view.c (year_view_mark_day): Use the same new version + of the range computation here. + + * calobj.c (ical_object_generate_events): Fix the begin/end + condition. + 1998-05-14 Miguel de Icaza <miguel@nuclecu.unam.mx> * timeutil.c (isodate_from_time_t): Do not add the spurious diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 7b9b42b716..1a9ef3f206 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -1049,8 +1049,8 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar int first_week_day, i; if (!ico->recur){ - if (time_in_range (ico->dtstart, start, end) || - time_in_range (ico->dtend, start, end)){ + if ((end && (ico->dtstart < end) && ico->dtend > start) || + (end == 0 && ico->dtend > start)){ time_t ev_s, ev_e; ev_s = ico->dtstart < start ? start : ico->dtstart; diff --git a/calendar/calobj.c b/calendar/calobj.c index 7b9b42b716..1a9ef3f206 100644 --- a/calendar/calobj.c +++ b/calendar/calobj.c @@ -1049,8 +1049,8 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar int first_week_day, i; if (!ico->recur){ - if (time_in_range (ico->dtstart, start, end) || - time_in_range (ico->dtend, start, end)){ + if ((end && (ico->dtstart < end) && ico->dtend > start) || + (end == 0 && ico->dtend > start)){ time_t ev_s, ev_e; ev_s = ico->dtstart < start ? start : ico->dtstart; diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c index 24c854ee5c..a54d4e4a78 100644 --- a/calendar/gnome-cal.c +++ b/calendar/gnome-cal.c @@ -335,19 +335,20 @@ static int mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c) { GtkCalendar *gtk_cal = c; - struct tm *tm_s; + struct tm tm_s; int days, day; + time_t t, day_end; - tm_s = localtime (&start); - days = difftime (end, start) / (60*60*24); - - for (day = 0; day <= days; day++){ - time_t new = mktime (tm_s); - struct tm *tm_day; + tm_s = *localtime (&start); + day_end = time_end_of_day (end); + + for (t = start; t <= day_end; t += 60*60*24){ + time_t new = mktime (&tm_s); + struct tm tm_day; - tm_day = localtime (&new); - gtk_calendar_mark_day (gtk_cal, tm_day->tm_mday); - tm_s->tm_mday++; + tm_day = *localtime (&new); + gtk_calendar_mark_day (gtk_cal, tm_day.tm_mday); + tm_s.tm_mday++; } return TRUE; } diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 24c854ee5c..a54d4e4a78 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -335,19 +335,20 @@ static int mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c) { GtkCalendar *gtk_cal = c; - struct tm *tm_s; + struct tm tm_s; int days, day; + time_t t, day_end; - tm_s = localtime (&start); - days = difftime (end, start) / (60*60*24); - - for (day = 0; day <= days; day++){ - time_t new = mktime (tm_s); - struct tm *tm_day; + tm_s = *localtime (&start); + day_end = time_end_of_day (end); + + for (t = start; t <= day_end; t += 60*60*24){ + time_t new = mktime (&tm_s); + struct tm tm_day; - tm_day = localtime (&new); - gtk_calendar_mark_day (gtk_cal, tm_day->tm_mday); - tm_s->tm_mday++; + tm_day = *localtime (&new); + gtk_calendar_mark_day (gtk_cal, tm_day.tm_mday); + tm_s.tm_mday++; } return TRUE; } diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c index bc03b4f36e..e8cb12feb3 100644 --- a/calendar/gui/year-view.c +++ b/calendar/gui/year-view.c @@ -168,20 +168,21 @@ static void year_view_mark_day (iCalObject *ical, time_t start, time_t end, void *closure) { GncalYearView *yview = (GncalYearView *) closure; - struct tm *tm_s; + struct tm tm_s; int days, day; - - tm_s = localtime (&start); - days = difftime (end, start) / (60*60*24); + time_t t, day_end; + + tm_s = *localtime (&start); + day_end = time_end_of_day (end); - for (day = 0; day <= days; day++){ - time_t new = mktime (tm_s); - struct tm *tm_day; + for (t = start; t <= day_end; t+= 60*60*24){ + time_t new = mktime (&tm_s); + struct tm tm_day; - tm_day = localtime (&new); - gtk_calendar_mark_day (GTK_CALENDAR (yview->calendar [tm_day->tm_mon]), - tm_day->tm_mday); - tm_s->tm_mday++; + tm_day = *localtime (&new); + gtk_calendar_mark_day (GTK_CALENDAR (yview->calendar [tm_day.tm_mon]), + tm_day.tm_mday); + tm_s.tm_mday++; } } diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c index 7b9b42b716..1a9ef3f206 100644 --- a/calendar/pcs/calobj.c +++ b/calendar/pcs/calobj.c @@ -1049,8 +1049,8 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar int first_week_day, i; if (!ico->recur){ - if (time_in_range (ico->dtstart, start, end) || - time_in_range (ico->dtend, start, end)){ + if ((end && (ico->dtstart < end) && ico->dtend > start) || + (end == 0 && ico->dtend > start)){ time_t ev_s, ev_e; ev_s = ico->dtstart < start ? start : ico->dtstart; diff --git a/calendar/year-view.c b/calendar/year-view.c index bc03b4f36e..e8cb12feb3 100644 --- a/calendar/year-view.c +++ b/calendar/year-view.c @@ -168,20 +168,21 @@ static void year_view_mark_day (iCalObject *ical, time_t start, time_t end, void *closure) { GncalYearView *yview = (GncalYearView *) closure; - struct tm *tm_s; + struct tm tm_s; int days, day; - - tm_s = localtime (&start); - days = difftime (end, start) / (60*60*24); + time_t t, day_end; + + tm_s = *localtime (&start); + day_end = time_end_of_day (end); - for (day = 0; day <= days; day++){ - time_t new = mktime (tm_s); - struct tm *tm_day; + for (t = start; t <= day_end; t+= 60*60*24){ + time_t new = mktime (&tm_s); + struct tm tm_day; - tm_day = localtime (&new); - gtk_calendar_mark_day (GTK_CALENDAR (yview->calendar [tm_day->tm_mon]), - tm_day->tm_mday); - tm_s->tm_mday++; + tm_day = *localtime (&new); + gtk_calendar_mark_day (GTK_CALENDAR (yview->calendar [tm_day.tm_mon]), + tm_day.tm_mday); + tm_s.tm_mday++; } } |