aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-10-25 01:27:22 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-10-25 01:27:22 +0800
commitc3876df777704e70f1d91689b4b29a69f8bf3e66 (patch)
treefe1e0265b9c69c3c5159a173177bf3102fb29d3b /calendar/cal-util
parent4d26929f07c5c34713671a36fb397dcc4522fcab (diff)
downloadgsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.tar.gz
gsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.tar.zst
gsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.zip
Fixes bug #5282.
2001-10-24 Federico Mena Quintero <federico@ximian.com> Fixes bug #5282. * cal-util/timeutil.c (icaltimetype_to_tm_with_zone): New function to avoid copying the same code all over the place. (icaltimetype_to_tm): Also set the tm.tm_wday. * gui/alarm-notify/alarm-queue.c (queue_midnight_refresh): Use time_day_end_with_zone(). (load_alarms_for_today): Likewise. And oops, we were only computing the times and not loading the alarms. (obj_updated_cb): Likewise. (load_alarms): Removed assertion that is no longer valid because we may load the alarms for a client in two stages. * gui/dialogs/alarm-page.c (get_alarm_string): Convert absolute trigger times to the local timezone. * gui/alarm-notify/alarm-notify-dialog.c (write_html_heading): Convert the times to the local timezone. (alarm_notify_dialog): Likewise, for the window title. (alarm_notify_dialog): Set the window layer to WIN_LAYER_ONTOP. * gui/e-cell-date-edit-text.c (ecd_get_text): Use icaltimetype_to_tm_with_zone(). * gui/alarm-notify/save.c (get_config_db): Made public. (discard_config_db): Made public. * gui/alarm-notify/config-data.[ch]: New files with functions to fetch the calendar configuration data used by the alarm daemon. svn path=/trunk/; revision=13986
Diffstat (limited to 'calendar/cal-util')
-rw-r--r--calendar/cal-util/timeutil.c38
-rw-r--r--calendar/cal-util/timeutil.h3
2 files changed, 40 insertions, 1 deletions
diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c
index 986971ef37..c6f6e33bcf 100644
--- a/calendar/cal-util/timeutil.c
+++ b/calendar/cal-util/timeutil.c
@@ -532,15 +532,51 @@ icaltimetype_to_tm (struct icaltimetype *itt)
tm.tm_min = itt->minute;
tm.tm_hour = itt->hour;
}
-
+
tm.tm_mday = itt->day;
tm.tm_mon = itt->month - 1;
tm.tm_year = itt->year - 1900;
+ tm.tm_wday = time_day_of_week (itt->day, itt->month - 1, itt->year);
tm.tm_isdst = -1;
return tm;
}
+/**
+ * icaltimetype_to_tm_with_zone:
+ * @itt: A time value.
+ * @from_zone: Source timezone.
+ * @to_zone: Destination timezone.
+ *
+ * Converts a time value from one timezone to another, and returns a struct tm
+ * representation of the time.
+ *
+ * Return value: The converted time as a struct tm. All fields will be
+ * set properly except for tm.tm_yday.
+ **/
+struct tm
+icaltimetype_to_tm_with_zone (struct icaltimetype *itt,
+ icaltimezone *from_zone,
+ icaltimezone *to_zone)
+{
+ struct tm tm;
+ struct icaltimetype itt_copy;
+
+ memset (&tm, 0, sizeof (tm));
+ tm.tm_isdst = -1;
+
+ g_return_val_if_fail (itt != NULL, tm);
+ g_return_val_if_fail (from_zone != NULL, tm);
+ g_return_val_if_fail (to_zone != NULL, tm);
+
+ itt_copy = *itt;
+
+ icaltimezone_convert_time (&itt_copy, from_zone, to_zone);
+ tm = icaltimetype_to_tm (&itt_copy);
+
+ return tm;
+}
+
struct icaltimetype
tm_to_icaltimetype (struct tm *tm, gboolean is_date)
{
diff --git a/calendar/cal-util/timeutil.h b/calendar/cal-util/timeutil.h
index 2ca61b45a2..77a8f180e1 100644
--- a/calendar/cal-util/timeutil.h
+++ b/calendar/cal-util/timeutil.h
@@ -114,6 +114,9 @@ void time_to_gdate_with_zone (GDate *date, time_t time, icaltimezone *zone);
**************************************************************************/
struct tm icaltimetype_to_tm (struct icaltimetype *itt);
+struct tm icaltimetype_to_tm_with_zone (struct icaltimetype *itt,
+ icaltimezone *from_zone,
+ icaltimezone *to_zone);
struct icaltimetype tm_to_icaltimetype (struct tm *tm, gboolean is_date);
#endif