From a71364b4a1e764bcbc31826bb632c1fa8e06eafb Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 17 Jul 2001 20:07:27 +0000 Subject: Really fixes #4380. The previous fix was necessary but not sufficient; it 2001-07-17 Federico Mena Quintero Really fixes #4380. The previous fix was necessary but not sufficient; it worked for me because my system timezone happens to match the Evolution timezone --- if they don't match, the bug would persist. * cal-util/timeutil.c (time_to_gdate_with_zone): New function. We cannot use g_date_set_time() anymore because it does not take timezones into account. * gui/gnome-cal.c (get_days_shown): Use the function above. * gui/e-day-view.c (e_day_view_find_work_week_start): Likewise. * gui/e-week-view.c (e_week_view_set_selected_time_range): Likewise. 2001-07-17 Jon Trowbridge svn path=/trunk/; revision=11167 --- calendar/cal-util/timeutil.c | 24 ++++++++++++++++++++++++ calendar/cal-util/timeutil.h | 1 + 2 files changed, 25 insertions(+) (limited to 'calendar/cal-util') diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c index 3a9308c1e1..f66d851399 100644 --- a/calendar/cal-util/timeutil.c +++ b/calendar/cal-util/timeutil.c @@ -393,6 +393,30 @@ time_day_end_with_zone (time_t time, icaltimezone *zone) return icaltime_as_timet_with_zone (tt, zone); } +/** + * time_to_gdate_with_zone: + * @date: Destination #GDate value. + * @time: A time value. + * @zone: Desired timezone for destination @date, or NULL if the UTC timezone + * is desired. + * + * Converts a time_t value to a #GDate structure using the specified timezone. + * This is analogous to g_date_set_time() but takes the timezone into account. + **/ +void +time_to_gdate_with_zone (GDate *date, time_t time, icaltimezone *zone) +{ + struct icaltimetype tt; + + g_return_if_fail (date != NULL); + g_return_if_fail (time != -1); + + tt = icaltime_from_timet_with_zone (time, FALSE, + zone ? zone : icaltimezone_get_utc_timezone ()); + + g_date_set_dmy (date, tt.day, tt.month, tt.year); +} + /************************************************************************** * General time functions. diff --git a/calendar/cal-util/timeutil.h b/calendar/cal-util/timeutil.h index 3679173572..0e2795b287 100644 --- a/calendar/cal-util/timeutil.h +++ b/calendar/cal-util/timeutil.h @@ -116,5 +116,6 @@ time_t time_day_begin_with_zone (time_t time, icaltimezone *zone); timezone. (The end of the day is the start of the next day.) */ time_t time_day_end_with_zone (time_t time, icaltimezone *zone); +void time_to_gdate_with_zone (GDate *date, time_t time, icaltimezone *zone); #endif -- cgit v1.2.3