From: <svn...@op...> - 2010-08-13 22:48:00
|
Author: cdfrey Date: Sat Aug 14 00:47:52 2010 New Revision: 6077 URL: http://www.opensync.org/changeset/6077 Log: Allow time functions to accept YYYY-MM-DDTHH:MM:SS formats Some formats, such as google calendar, hold timestamps in a format that includes dashes and colons. It makes sense to accept both in the library time routines. Modified: trunk/opensync/format/opensync_time.c Modified: trunk/opensync/format/opensync_time.c ============================================================================== --- trunk/opensync/format/opensync_time.c Sat Aug 14 00:47:44 2010 (r6076) +++ trunk/opensync/format/opensync_time.c Sat Aug 14 00:47:52 2010 (r6077) @@ -166,7 +166,8 @@ { osync_trace(TRACE_ENTRY, "%s(%s)", __func__, vtime); struct tm *utime = g_try_malloc0(sizeof(struct tm)); - + char *plainvtime = NULL; + if (!utime) { osync_error_set(error, OSYNC_ERROR_GENERIC, "Could not allocate memory for time stuct."); goto error; @@ -179,7 +180,10 @@ utime->tm_min = 0; utime->tm_sec = 0; - sscanf(vtime, "%04d%02d%02dT%02d%02d%02d%*01c", + // make sure vtime is in format: YYYYMMDDTHHMMSS... + plainvtime = osync_time_timestamp_remove_dash(vtime); + + sscanf(plainvtime, "%04d%02d%02dT%02d%02d%02d%*01c", &(utime->tm_year), &(utime->tm_mon), &(utime->tm_mday), &(utime->tm_hour), &(utime->tm_min), &(utime->tm_sec)); @@ -192,6 +196,7 @@ /* ask C library to clean up any anomalies */ mktime(utime); + free(plainvtime); osync_trace(TRACE_EXIT, "%s", __func__); return utime; error: |