aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog5
-rw-r--r--calendar/cal-util/calobj.c15
-rw-r--r--calendar/calendar.c1
-rw-r--r--calendar/calobj.c15
-rw-r--r--calendar/gncal-day-panel.c5
-rw-r--r--calendar/gui/calendar.c1
-rw-r--r--calendar/gui/gncal-day-panel.c5
-rw-r--r--calendar/pcs/calobj.c15
-rw-r--r--calendar/timeutil.c56
9 files changed, 102 insertions, 16 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index b6364c70f1..5e3246578d 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,8 @@
+1999-03-10 Craig A Soules (soules+@andrew.cmu.edu)
+
+ * timeutil.c, calendar.c, calobj.c, gncal-day-panel.c: Add support
+ for daylight time savings.
+
1999-02-28 Martin Baulig <martin@home-of-linux.org>
* gncal-full-day.c (recompute_motion): For DRAG_MOVE, DRAG_SIZE_TOP
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index 6ed9db187a..db27f8abd3 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -1030,12 +1030,22 @@ generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
dt_end.tm_mon = ref.tm_mon;
dt_end.tm_year = ref.tm_year;
+
+ if (ref.tm_isdst > dt_start.tm_isdst){
+ dt_start.tm_hour--;
+ dt_end.tm_hour--;
+ } else if (ref.tm_isdst < dt_start.tm_isdst){
+ dt_start.tm_hour++;
+ dt_end.tm_hour++;
+ }
+
s_t = mktime (&dt_start);
+
if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
return 1;
e_t = mktime (&dt_end);
-
+
if ((s_t == -1) || (e_t == -1)) {
g_warning ("Produced invalid dates!\n");
return 0;
@@ -1131,9 +1141,10 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) {
/* Weekdays to recur on are specified as a bitmask */
- if (ico->recur->weekday & (1 << tm->tm_wday))
+ if (ico->recur->weekday & (1 << tm->tm_wday)) {
if (!generate (ico, current, cb, closure))
return;
+ }
}
/* Advance by day for scanning the week or by interval at week end */
diff --git a/calendar/calendar.c b/calendar/calendar.c
index 024e2d0116..dbe1bf7e47 100644
--- a/calendar/calendar.c
+++ b/calendar/calendar.c
@@ -401,6 +401,7 @@ assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c)
GList **l = c;
co = g_new (CalendarObject, 1);
+
co->ev_start = start;
co->ev_end = end;
co->ico = obj;
diff --git a/calendar/calobj.c b/calendar/calobj.c
index 6ed9db187a..db27f8abd3 100644
--- a/calendar/calobj.c
+++ b/calendar/calobj.c
@@ -1030,12 +1030,22 @@ generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
dt_end.tm_mon = ref.tm_mon;
dt_end.tm_year = ref.tm_year;
+
+ if (ref.tm_isdst > dt_start.tm_isdst){
+ dt_start.tm_hour--;
+ dt_end.tm_hour--;
+ } else if (ref.tm_isdst < dt_start.tm_isdst){
+ dt_start.tm_hour++;
+ dt_end.tm_hour++;
+ }
+
s_t = mktime (&dt_start);
+
if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
return 1;
e_t = mktime (&dt_end);
-
+
if ((s_t == -1) || (e_t == -1)) {
g_warning ("Produced invalid dates!\n");
return 0;
@@ -1131,9 +1141,10 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) {
/* Weekdays to recur on are specified as a bitmask */
- if (ico->recur->weekday & (1 << tm->tm_wday))
+ if (ico->recur->weekday & (1 << tm->tm_wday)) {
if (!generate (ico, current, cb, closure))
return;
+ }
}
/* Advance by day for scanning the week or by interval at week end */
diff --git a/calendar/gncal-day-panel.c b/calendar/gncal-day-panel.c
index 57df9acc3b..518babfa1a 100644
--- a/calendar/gncal-day-panel.c
+++ b/calendar/gncal-day-panel.c
@@ -71,13 +71,14 @@ calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel)
{
gint y, m, d;
struct tm tm;
+ time_t time;
gtk_calendar_get_date (calendar, &y, &m, &d);
tm.tm_year = y - 1900;
tm.tm_mon = m;
tm.tm_mday = d;
- tm.tm_hour = 0;
+ tm.tm_hour = 5; /* for daylight savings time fix */
tm.tm_min = 0;
tm.tm_sec = 0;
@@ -233,7 +234,7 @@ gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day)
g_return_if_fail (dpanel != NULL);
g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
- dpanel->start_of_day = time_day_begin (start_of_day);
+ dpanel->start_of_day = time_day_begin(start_of_day);
if (dpanel->fullday->lower == dpanel->start_of_day)
return;
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 024e2d0116..dbe1bf7e47 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -401,6 +401,7 @@ assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c)
GList **l = c;
co = g_new (CalendarObject, 1);
+
co->ev_start = start;
co->ev_end = end;
co->ico = obj;
diff --git a/calendar/gui/gncal-day-panel.c b/calendar/gui/gncal-day-panel.c
index 57df9acc3b..518babfa1a 100644
--- a/calendar/gui/gncal-day-panel.c
+++ b/calendar/gui/gncal-day-panel.c
@@ -71,13 +71,14 @@ calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel)
{
gint y, m, d;
struct tm tm;
+ time_t time;
gtk_calendar_get_date (calendar, &y, &m, &d);
tm.tm_year = y - 1900;
tm.tm_mon = m;
tm.tm_mday = d;
- tm.tm_hour = 0;
+ tm.tm_hour = 5; /* for daylight savings time fix */
tm.tm_min = 0;
tm.tm_sec = 0;
@@ -233,7 +234,7 @@ gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day)
g_return_if_fail (dpanel != NULL);
g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
- dpanel->start_of_day = time_day_begin (start_of_day);
+ dpanel->start_of_day = time_day_begin(start_of_day);
if (dpanel->fullday->lower == dpanel->start_of_day)
return;
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
index 6ed9db187a..db27f8abd3 100644
--- a/calendar/pcs/calobj.c
+++ b/calendar/pcs/calobj.c
@@ -1030,12 +1030,22 @@ generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
dt_end.tm_mon = ref.tm_mon;
dt_end.tm_year = ref.tm_year;
+
+ if (ref.tm_isdst > dt_start.tm_isdst){
+ dt_start.tm_hour--;
+ dt_end.tm_hour--;
+ } else if (ref.tm_isdst < dt_start.tm_isdst){
+ dt_start.tm_hour++;
+ dt_end.tm_hour++;
+ }
+
s_t = mktime (&dt_start);
+
if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
return 1;
e_t = mktime (&dt_end);
-
+
if ((s_t == -1) || (e_t == -1)) {
g_warning ("Produced invalid dates!\n");
return 0;
@@ -1131,9 +1141,10 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) {
/* Weekdays to recur on are specified as a bitmask */
- if (ico->recur->weekday & (1 << tm->tm_wday))
+ if (ico->recur->weekday & (1 << tm->tm_wday)) {
if (!generate (ico, current, cb, closure))
return;
+ }
}
/* Advance by day for scanning the week or by interval at week end */
diff --git a/calendar/timeutil.c b/calendar/timeutil.c
index 07a1514c80..c03f2cb565 100644
--- a/calendar/timeutil.c
+++ b/calendar/timeutil.c
@@ -109,13 +109,24 @@ time_add_day (time_t time, int days)
{
struct tm *tm = localtime (&time);
time_t new_time;
+ int dst_flag = tm->tm_isdst;
tm->tm_mday += days;
+
if ((new_time = mktime (tm)) == -1){
g_warning ("mktime could not handling adding a day with\n");
print_time_t (time);
return time;
}
+
+ 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;
+ }
+
return new_time;
}
@@ -306,27 +317,60 @@ time_t
time_day_begin (time_t t)
{
struct tm tm;
+ time_t temp = t - 43200;
+ int dstflag, dstflag2;
+ tm = *localtime(&temp); /* one day */
+ dstflag = tm.tm_isdst;
+
tm = *localtime (&t);
- tm.tm_hour = 0;
+ dstflag2 = tm.tm_isdst;
+
+ if (dstflag < dstflag2)
+ tm.tm_hour = 1;
+ else
+ tm.tm_hour = 0;
+
tm.tm_min = 0;
tm.tm_sec = 0;
+
+ temp = mktime(&tm);
+ if (dstflag > dstflag2){
+ temp += 3600;
+ }
- return mktime (&tm);
+ return temp;
}
time_t
time_day_end (time_t t)
{
struct tm tm;
-
+ time_t temp;
+ int dstflag, dstflag2;
+
+ t += 10800;
+ temp = t - 86400;
+
+ tm = *localtime(&temp); /* one day */
+ dstflag = tm.tm_isdst;
+
tm = *localtime (&t);
- tm.tm_hour = 0;
+ dstflag2 = tm.tm_isdst;
+
+ if (dstflag < dstflag2)
+ tm.tm_hour = 23;
+ else {
+ tm.tm_mday++;
+ tm.tm_hour = 0;
+ }
tm.tm_min = 0;
tm.tm_sec = 0;
- tm.tm_mday++;
- return mktime (&tm);
+ temp = mktime(&tm);
+ if(dstflag > dstflag2) {
+ }
+ return temp;
}
static char *