aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/calendar-model.c
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-07-03 12:21:37 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-07-03 12:21:37 +0800
commit642d32d63f226cd1ba049a9d979132e1a1cef94d (patch)
treebe4ef8fb72ca41391007554a6cbe97af41533555 /calendar/gui/calendar-model.c
parentbacd3a85a434032316b3e63b95282175ce2b0659 (diff)
downloadgsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.gz
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.bz2
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.lz
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.xz
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.zst
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.zip
cal-client/cal-client.[hc] cal-util/cal-component.c
2001-07-03 Damon Chaplin <damon@ximian.com> * cal-client/cal-client.[hc] * cal-util/cal-component.c * cal-util/cal-recur.[hc] * cal-util/test-recur.c * cal-util/timeutil.c * gui/calendar-config.c * gui/calendar-model.[hc] * gui/comp-util.[hc] * gui/e-calendar-table.c * gui/e-day-view-main-item.c * gui/e-day-view-top-item.c * gui/e-day-view.[hc] * gui/e-itip-control.c * gui/e-timezone-entry.[hc] * gui/e-week-view.[hc] * gui/gnome-cal.[hc] * gui/goto.c * gui/tag-calendar.[hc] * gui/dialogs/cal-prefs-dialog.c * gui/dialogs/comp-editor-page.[hc] * gui/dialogs/comp-editor-util.[hc] * gui/dialogs/comp-editor.c * gui/dialogs/e-timezone-dialog.[hc] * gui/dialogs/event-page.c * gui/dialogs/meeting-page.c * gui/dialogs/recurrence-page.c * gui/dialogs/task-details-page.c * gui/dialogs/task-details-page.glade * gui/dialogs/task-page.c * idl/evolution-calendar.idl * pcs/cal-backend-file.c * pcs/cal-backend.c * pcs/cal-backend.h * pcs/cal.c * pcs/query.c: timezone changes everywhere. There's still quite a few things to update, and its not working well at present. svn path=/trunk/; revision=10729
Diffstat (limited to 'calendar/gui/calendar-model.c')
-rw-r--r--calendar/gui/calendar-model.c70
1 files changed, 61 insertions, 9 deletions
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index bcd4d69843..6d1625238d 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -75,6 +75,9 @@ struct _CalendarModelPrivate {
/* A balanced tree of the categories used by all the tasks/events. */
GTree *categories;
+
+ /* The current timezone. */
+ icaltimezone *zone;
};
enum {
@@ -201,6 +204,8 @@ calendar_model_init (CalendarModel *model)
priv->use_24_hour_format = TRUE;
priv->categories = g_tree_new ((GCompareFunc)strcmp);
+
+ priv->zone = NULL;
}
/* Called from g_hash_table_foreach_remove(), frees a stored UID->index
@@ -317,13 +322,26 @@ static char*
get_time_t (CalendarModel *model, time_t *t, gboolean show_midnight)
{
static char buffer[64];
- struct tm *tmp_tm;
+ struct tm tmp_tm;
+ struct icaltimetype tt;
if (*t <= 0) {
buffer[0] = '\0';
} else {
- tmp_tm = localtime (t);
- e_time_format_date_and_time (tmp_tm,
+ tt = icaltime_from_timet_with_zone (*t, FALSE,
+ model->priv->zone);
+ tmp_tm.tm_year = tt.year - 1900;
+ tmp_tm.tm_mon = tt.month - 1;
+ tmp_tm.tm_mday = tt.day;
+ tmp_tm.tm_hour = tt.hour;
+ tmp_tm.tm_min = tt.minute;
+ tmp_tm.tm_sec = tt.second;
+ tmp_tm.tm_isdst = -1;
+
+ /* Call mktime() to set the weekday. */
+ mktime (&tmp_tm);
+
+ e_time_format_date_and_time (&tmp_tm,
model->priv->use_24_hour_format,
show_midnight, FALSE,
buffer, sizeof (buffer));
@@ -383,12 +401,15 @@ get_completed (CalendarModel *model,
struct icaltimetype *completed;
time_t t;
+ /* FIXME: COMPLETED is in UTC, but we probably want to show it in
+ the current timezone. */
+
cal_component_get_completed (comp, &completed);
if (!completed)
t = 0;
else {
- t = icaltime_as_timet (*completed);
+ t = icaltime_as_timet_with_zone (*completed, icaltimezone_get_utc_timezone ());
cal_component_free_icaltimetype (completed);
}
@@ -840,6 +861,8 @@ show_date_warning (CalendarModel *model)
struct tm *tmp_tm;
t = time (NULL);
+ /* We are only using this as an example, so the timezone doesn't
+ matter. */
tmp_tm = localtime (&t);
if (model->priv->use_24_hour_format)
@@ -972,6 +995,9 @@ set_completed (CalendarModel *model, CalComponent *comp, const char *value)
struct tm tmp_tm;
time_t t;
+ /* FIXME: COMPLETED is in UTC, but we probably want to show it in
+ the current timezone. */
+
status = e_time_parse_date_and_time (value, &tmp_tm);
if (status == E_TIME_PARSE_INVALID) {
@@ -991,7 +1017,6 @@ set_datetime (CalendarModel *model, CalComponent *comp, const char *value,
{
ETimeParseStatus status;
struct tm tmp_tm;
- time_t t;
status = e_time_parse_date_and_time (value, &tmp_tm);
@@ -1001,12 +1026,18 @@ set_datetime (CalendarModel *model, CalComponent *comp, const char *value,
(* set_func) (comp, NULL);
} else {
CalComponentDateTime dt;
- struct icaltimetype itt;
+ struct icaltimetype itt = icaltime_null_time ();
+
+ itt.year = tmp_tm.tm_year + 1900;
+ itt.month = tmp_tm.tm_mon + 1;
+ itt.day = tmp_tm.tm_mday;
+ itt.hour = tmp_tm.tm_hour;
+ itt.minute = tmp_tm.tm_min;
+ itt.second = tmp_tm.tm_sec;
- t = mktime (&tmp_tm);
- itt = icaltime_from_timet (t, FALSE);
dt.value = &itt;
- dt.tzid = NULL;
+ /* We assume it is being set to the current timezone. */
+ dt.tzid = icaltimezone_get_tzid (model->priv->zone);
(* set_func) (comp, &dt);
}
@@ -2305,3 +2336,24 @@ calendar_model_get_categories (CalendarModel *model)
return model->priv->categories;
}
+
+
+/* The current timezone. */
+icaltimezone*
+calendar_model_get_timezone (CalendarModel *model)
+{
+ g_return_val_if_fail (IS_CALENDAR_MODEL (model), NULL);
+
+ return model->priv->zone;
+}
+
+
+void
+calendar_model_set_timezone (CalendarModel *model,
+ icaltimezone *zone)
+{
+ g_return_if_fail (IS_CALENDAR_MODEL (model));
+
+ if (model->priv->zone != zone)
+ model->priv->zone = zone;
+}