From 5b6b5aff4268e3d99193ea5087728603b0124b85 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 19 Jan 2001 14:55:26 +0000 Subject: add -ve sign to output of duration if appropriate. 2001-01-19 JP Rosevear * src/libical/icalvalue.c.in (icalvalue_duration_as_ical_string): add -ve sign to output of duration if appropriate. (icalvalue_trigger_as_ical_string): implement. not happy how this is done with the -1 for is_date trick but it will do for now and period does things in a similar way. svn path=/trunk/; revision=7645 --- libical/src/libical/icalvalue.c.in | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'libical') diff --git a/libical/src/libical/icalvalue.c.in b/libical/src/libical/icalvalue.c.in index 7adcecb990..ae48207f42 100644 --- a/libical/src/libical/icalvalue.c.in +++ b/libical/src/libical/icalvalue.c.in @@ -3,7 +3,7 @@ FILE: icalvalue.c CREATOR: eric 02 May 1999 - $Id: icalvalue.c.in,v 1.1 2000/12/11 22:06:02 federico Exp $ + $Id: icalvalue.c.in,v 1.2 2001/01/19 14:55:26 jpr Exp $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org @@ -838,7 +838,8 @@ void append_duration_segment(char** buf, char** buf_ptr, size_t* buf_size, } -char* icalvalue_duration_as_ical_string(icalvalue* value) { +char* icalvalue_duration_as_ical_string(icalvalue* value) +{ struct icaldurationtype data; char *buf, *output_line; @@ -851,6 +852,8 @@ char* icalvalue_duration_as_ical_string(icalvalue* value) { buf = (char*)icalmemory_new_buffer(buf_size); buf_ptr = buf; + if (data.is_neg) + icalmemory_append_string(&buf, &buf_ptr, &buf_size, "-"); icalmemory_append_string(&buf, &buf_ptr, &buf_size, "P"); @@ -1081,16 +1084,33 @@ char* icalvalue_period_as_ical_string(icalvalue* value) { return str; } -char* icalvalue_trigger_as_ical_string(icalvalue* value) { +char* icalvalue_trigger_as_ical_string(icalvalue* value) +{ union icaltriggertype data; char* str; + icalvalue *e; + icalerror_check_arg_rz( (value!=0),"value"); data = icalvalue_get_trigger(value); - + str = (char*)icalmemory_tmp_buffer(60); - sprintf(str,"icalvalue_trigger_as_ical_string is not implemented yet"); + if (data.time.is_date != -1){ + /* use the absolute date */ + e = icalvalue_new_datetime(data.time); + + strcpy (str, icalvalue_datetime_as_ical_string(e)); + + } else { + /* use the duration */ + e = icalvalue_new_duration(data.duration); + + strcpy (str, icalvalue_duration_as_ical_string(e)); + + } + + icalvalue_free(e); return str; } -- cgit