summaryrefslogtreecommitdiff
path: root/gpsutils.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2007-12-12 04:18:44 +0000
committerEric S. Raymond <esr@thyrsus.com>2007-12-12 04:18:44 +0000
commita4d6208874dbd0d0293853ece8d2f69f27bb4e82 (patch)
tree264bd0bf525ed2e569ef3fe22f81fc762683bbb4 /gpsutils.c
parentc43c9c804246c540aafd0e34c87c3fd9ea0f6925 (diff)
downloadgpsd-a4d6208874dbd0d0293853ece8d2f69f27bb4e82.tar.gz
Fix patch by Petr Slansky.
Diffstat (limited to 'gpsutils.c')
-rw-r--r--gpsutils.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gpsutils.c b/gpsutils.c
index 3ca0c744..7075b17e 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -184,22 +184,22 @@ double iso8601_to_unix(/*@in@*/char *isotime)
/*@observer@*/char *unix_to_iso8601(double fixtime, /*@ out @*/char isotime[], size_t len)
/* Unix UTC time to ISO8601, no timezone adjustment */
+/* example: 2007-12-11T23:38:51.0Z */
{
struct tm when;
double integral, fractional;
time_t intfixtime;
- size_t slen;
- char fractstr[20];
+ char timestr[30];
+ char fractstr[10];
fractional = modf(fixtime, &integral);
intfixtime = (time_t)integral;
(void)gmtime_r(&intfixtime, &when);
- (void)strftime(isotime, len, "%Y-%m-%dT%H:%M:%S", &when);
- slen = strlen(isotime);
+ (void)strftime(timestr, sizeof(timestr), "%Y-%m-%dT%H:%M:%S", &when);
(void)snprintf(fractstr, sizeof(fractstr), "%.1f", fractional);
/* add fractional part, ignore leading 0; "0.2" -> ".2" */
- (void)snprintf(isotime + slen, (size_t)(len - slen), "%sZ", fractstr+1);
+ (void)snprintf(isotime, len, "%s%sZ", timestr, fractstr+1);
return isotime;
}