From 31675e8d99ca20c77f322f69bccc8eb64e4ca63e Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Tue, 23 Oct 2001 17:40:55 +0000 Subject: convert an icaltimetype to a tm (tm_to_icaltimetype): vice versa 2001-10-23 JP Rosevear * cal-util/timeutil.c (icaltimetype_to_tm): convert an icaltimetype to a tm (tm_to_icaltimetype): vice versa * cal-util/timeutil.h: new protos * conduits/calendar/calendar-conduit.c: replace all mktime and localtime calls (except for debugging calls) * conduits/todo/todo-conduit.c: ditto (comp_from_remote_record): make sure the completed time is in UTC svn path=/trunk/; revision=13946 --- calendar/conduits/todo/todo-conduit.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'calendar/conduits/todo/todo-conduit.c') diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c index ca59b04bd6..ed039b10b7 100644 --- a/calendar/conduits/todo/todo-conduit.c +++ b/calendar/conduits/todo/todo-conduit.c @@ -364,9 +364,9 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui GSList *d_list = NULL; CalComponentText *description; CalComponentDateTime due; - time_t due_time; CalComponentClassification classif; - + icaltimezone *default_tz = get_default_timezone (); + LOG ("local_record_from_comp\n"); g_return_if_fail (local != NULL); @@ -417,9 +417,10 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui cal_component_get_due (comp, &due); if (due.value) { - due_time = icaltime_as_timet_with_zone (*due.value, get_timezone (ctxt->client, due.tzid)); - - local->todo->due = *localtime (&due_time); + icaltimezone_convert_time (due.value, + get_timezone (ctxt->client, due.tzid), + default_tz); + local->todo->due = icaltimetype_to_tm (due.value); local->todo->indefinite = 0; } else { local->todo->indefinite = 1; @@ -493,10 +494,10 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, { CalComponent *comp; struct ToDo todo; - struct icaltimetype now = icaltime_from_timet_with_zone (time (NULL), FALSE, timezone); CalComponentText summary = {NULL, NULL}; CalComponentDateTime dt = {NULL, icaltimezone_get_tzid (timezone)}; - struct icaltimetype due; + struct icaltimetype due, now; + icaltimezone *utc_zone; int priority; char *txt; @@ -505,6 +506,10 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, memset (&todo, 0, sizeof (struct ToDo)); unpack_ToDo (&todo, remote->record, remote->length); + utc_zone = icaltimezone_get_utc_timezone (); + now = icaltime_from_timet_with_zone (time (NULL), FALSE, + utc_zone); + if (in_comp == NULL) { comp = cal_component_new (); cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); @@ -537,12 +542,13 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, if (todo.complete) { int percent = 100; + cal_component_set_completed (comp, &now); cal_component_set_percent (comp, &percent); } if (!is_empty_time (todo.due)) { - due = icaltime_from_timet_with_zone (mktime (&todo.due), FALSE, timezone); + due = tm_to_icaltimetype (&todo.due, FALSE); dt.value = &due; cal_component_set_due (comp, &dt); } -- cgit v1.2.3