Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH obexd] phonebook-tracker.c: Fix iso8601_utc_to_localtime
@ 2011-12-08  9:41 Slawomir Bochenski
  2011-12-08 10:50 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Slawomir Bochenski @ 2011-12-08  9:41 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Slawomir Bochenski

Timestamp returned from Tracker can optionally contain fractional
seconds. Original code treated any character after seconds as flag for
UTC timestamp. This patch changes it so now only the beginning of string
is scanned and the end of string is checked for UTC flag ('Z') presence.
---
 plugins/phonebook-tracker.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 61c7af9..da82ff5 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -728,15 +728,13 @@ static char *iso8601_utc_to_localtime(const char *datetime)
 	time_t time;
 	struct tm tm, *local;
 	char localdate[32];
-	char tz;
 	int nr;
 
 	memset(&tm, 0, sizeof(tm));
 
-	nr = sscanf(datetime, "%04u-%02u-%02uT%02u:%02u:%02u%c",
+	nr = sscanf(datetime, "%04u-%02u-%02uT%02u:%02u:%02u",
 			&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
-			&tm.tm_hour, &tm.tm_min, &tm.tm_sec,
-			&tz);
+			&tm.tm_hour, &tm.tm_min, &tm.tm_sec);
 	if (nr < 6) {
 		/* Invalid time format */
 		error("sscanf(): %s (%d)", strerror(errno), errno);
@@ -744,7 +742,7 @@ static char *iso8601_utc_to_localtime(const char *datetime)
 	}
 
 	/* Time already in localtime */
-	if (nr == 6) {
+	if (!g_str_has_suffix(datetime, "Z")) {
 		strftime(localdate, sizeof(localdate), "%Y%m%dT%H%M%S", &tm);
 		return g_strdup(localdate);
 	}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH obexd] phonebook-tracker.c: Fix iso8601_utc_to_localtime
  2011-12-08  9:41 [PATCH obexd] phonebook-tracker.c: Fix iso8601_utc_to_localtime Slawomir Bochenski
@ 2011-12-08 10:50 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2011-12-08 10:50 UTC (permalink / raw)
  To: Slawomir Bochenski; +Cc: linux-bluetooth

Hi Slawek,

On Thu, Dec 08, 2011, Slawomir Bochenski wrote:
> Timestamp returned from Tracker can optionally contain fractional
> seconds. Original code treated any character after seconds as flag for
> UTC timestamp. This patch changes it so now only the beginning of string
> is scanned and the end of string is checked for UTC flag ('Z') presence.
> ---
>  plugins/phonebook-tracker.c |    8 +++-----
>  1 files changed, 3 insertions(+), 5 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-08 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-08  9:41 [PATCH obexd] phonebook-tracker.c: Fix iso8601_utc_to_localtime Slawomir Bochenski
2011-12-08 10:50 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox