Skip to contentSkip to conversation

Fix regression when formatting timestamps from tracker

PATCH In review Luiz Augusto von Dentz 2 participants 2 messages Oct 19, 2010 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 Fix regression when formatting timestamps from tracker

From: Luiz Augusto von Dentz <[email protected]>

Tracker format user delimiters like '-' and ':' which need to be keep in order to sscanf to work.

---
 plugins/phonebook-tracker.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
plugins/phonebook-tracker.c +6 -3
index 2da825b..f0e00b8 100644
@@ -705,18 +705,21 @@ static char *iso8601_utc_to_localtime(const char *datetime)
 
 	memset(&tm, 0, sizeof(tm));
 
-	nr = sscanf(datetime, "%04u%02u%02uT%02u%02u%02u%c",
+	nr = sscanf(datetime, "%04u-%02u-%02uT%02u:%02u:%02u%c",
 			&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
 			&tm.tm_hour, &tm.tm_min, &tm.tm_sec,
 			&tz);
 	if (nr < 6) {
 		/* Invalid time format */
+		error("sscanf(): %s (%d)", strerror(errno), errno);
 		return g_strdup("");
 	}
 
 	/* Time already in localtime */
-	if (nr == 6)
-		return g_strdup(datetime);
+	if (nr == 6) {
+		strftime(localdate, sizeof(localdate), "%Y%m%dT%H%M%S", &tm);
+		return g_strdup(localdate);
+	}
 
 	tm.tm_year -= 1900;	/* Year since 1900 */
 	tm.tm_mon--;		/* Months since January, values 0-11 */
Signature · 1 line
1.7.1
#1 lore raw

Hi Luiz,

Quoted 7 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Tracker format user delimiters like '-' and ':' which need to be keep in order to sscanf to work.

---
 plugins/phonebook-tracker.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

Pushed upstream. Thanks.

Johan