diff options
author | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-22 09:15:42 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-22 09:15:42 +0800 |
commit | 1e77e73903d1604ed8b46c9979ef2d948c46383c (patch) | |
tree | f577617200ca81a52ed6d50ee45ab8ac92149c08 | |
parent | 45abc2cbefa6d1dfafeb6a8351c35d5c841f87c8 (diff) | |
download | gsoc2013-evolution-1e77e73903d1604ed8b46c9979ef2d948c46383c.tar gsoc2013-evolution-1e77e73903d1604ed8b46c9979ef2d948c46383c.tar.gz gsoc2013-evolution-1e77e73903d1604ed8b46c9979ef2d948c46383c.tar.bz2 gsoc2013-evolution-1e77e73903d1604ed8b46c9979ef2d948c46383c.tar.lz gsoc2013-evolution-1e77e73903d1604ed8b46c9979ef2d948c46383c.tar.xz gsoc2013-evolution-1e77e73903d1604ed8b46c9979ef2d948c46383c.tar.zst gsoc2013-evolution-1e77e73903d1604ed8b46c9979ef2d948c46383c.zip |
Small fix for goto-day-year computation -mig
svn path=/trunk/; revision=179
-rw-r--r-- | calendar/ChangeLog | 6 | ||||
-rw-r--r-- | calendar/gncal-day-panel.c | 2 | ||||
-rw-r--r-- | calendar/gncal-week-view.c | 20 | ||||
-rw-r--r-- | calendar/gnome-cal.c | 3 | ||||
-rw-r--r-- | calendar/gui/gncal-day-panel.c | 2 | ||||
-rw-r--r-- | calendar/gui/gncal-week-view.c | 20 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 3 |
7 files changed, 36 insertions, 20 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index e3adbf056f..de55fa246f 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,7 +1,13 @@ 1998-04-21 Miguel de Icaza <miguel@nuclecu.unam.mx> + * gncal-day-panel.c (calendar_day_selected): Fix, years for mktime + should substract 1900 and gtk_calendar stores years relative to + year 0. + * gncal-week-view.c (gncal_week_view_new): Make the week view descend from VBox so that we can add a label to it. + (gncal_week_view_set): Display the ending day of the week + correctly. Added a label that displays the week range. diff --git a/calendar/gncal-day-panel.c b/calendar/gncal-day-panel.c index 099b02f384..3cf2f57b24 100644 --- a/calendar/gncal-day-panel.c +++ b/calendar/gncal-day-panel.c @@ -65,7 +65,7 @@ calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel) gtk_calendar_get_date (calendar, &y, &m, &d); - tm.tm_year = y; + tm.tm_year = y - 1900; tm.tm_mon = m; tm.tm_mday = d; tm.tm_hour = 0; diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c index 7de8899cb3..ab5e7fbea0 100644 --- a/calendar/gncal-week-view.c +++ b/calendar/gncal-week-view.c @@ -175,8 +175,8 @@ gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags) void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week) { - struct tm tm, start; - time_t day_start, day_end; + struct tm tm; + time_t day_start, day_end, week_start, week_end; int i; g_return_if_fail (wview != NULL); @@ -187,15 +187,14 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week) /* back up to start of week (Monday) */ tm.tm_mday -= (tm.tm_wday == 0) ? 6 : (tm.tm_wday - 1); - + /* Start of day */ tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; - day_start = mktime (&tm); - start = tm; + day_start = week_start = mktime (&tm); /* Calendar */ @@ -218,11 +217,16 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week) { char buf [80]; int len; + struct tm *t; - strftime (buf, sizeof (buf), "%A %d %Y - ", &start); - len = strlen (buf); + week_end = time_add_day (week_start, 6); + t = localtime (&week_start); - strftime (buf + len, sizeof (buf) - len, "%A %d %Y", &tm); + strftime (buf, sizeof (buf), "%A %d %Y - ", t); + len = strlen (buf); + + t = localtime (&week_end); + strftime (buf + len, sizeof (buf) - len, "%A %d %Y", t); gtk_label_set (GTK_LABEL (wview->label), buf); } diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c index a71e7fb343..e1c300071d 100644 --- a/calendar/gnome-cal.c +++ b/calendar/gnome-cal.c @@ -74,7 +74,8 @@ void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time) { GtkWidget *current = get_current_page (gcal); - g_assert (new_time != -1); + + g_return_if_fail (new_time != -1); if (current == gcal->day_view) gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time); diff --git a/calendar/gui/gncal-day-panel.c b/calendar/gui/gncal-day-panel.c index 099b02f384..3cf2f57b24 100644 --- a/calendar/gui/gncal-day-panel.c +++ b/calendar/gui/gncal-day-panel.c @@ -65,7 +65,7 @@ calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel) gtk_calendar_get_date (calendar, &y, &m, &d); - tm.tm_year = y; + tm.tm_year = y - 1900; tm.tm_mon = m; tm.tm_mday = d; tm.tm_hour = 0; diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c index 7de8899cb3..ab5e7fbea0 100644 --- a/calendar/gui/gncal-week-view.c +++ b/calendar/gui/gncal-week-view.c @@ -175,8 +175,8 @@ gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags) void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week) { - struct tm tm, start; - time_t day_start, day_end; + struct tm tm; + time_t day_start, day_end, week_start, week_end; int i; g_return_if_fail (wview != NULL); @@ -187,15 +187,14 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week) /* back up to start of week (Monday) */ tm.tm_mday -= (tm.tm_wday == 0) ? 6 : (tm.tm_wday - 1); - + /* Start of day */ tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; - day_start = mktime (&tm); - start = tm; + day_start = week_start = mktime (&tm); /* Calendar */ @@ -218,11 +217,16 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week) { char buf [80]; int len; + struct tm *t; - strftime (buf, sizeof (buf), "%A %d %Y - ", &start); - len = strlen (buf); + week_end = time_add_day (week_start, 6); + t = localtime (&week_start); - strftime (buf + len, sizeof (buf) - len, "%A %d %Y", &tm); + strftime (buf, sizeof (buf), "%A %d %Y - ", t); + len = strlen (buf); + + t = localtime (&week_end); + strftime (buf + len, sizeof (buf) - len, "%A %d %Y", t); gtk_label_set (GTK_LABEL (wview->label), buf); } diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index a71e7fb343..e1c300071d 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -74,7 +74,8 @@ void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time) { GtkWidget *current = get_current_page (gcal); - g_assert (new_time != -1); + + g_return_if_fail (new_time != -1); if (current == gcal->day_view) gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time); |