gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-users] Build broken for non-QT


From: O'Connor, Daniel
Subject: Re: [gpsd-users] Build broken for non-QT
Date: Tue, 13 Jan 2015 21:31:30 +1030

> On 13 Jan 2015, at 20:58, Eric S. Raymond <address@hidden> wrote:
>> AFAIK there is no truly portable way to do it but in practise you can use 
>> timegm to convert a struct tm to a UTC time_t.
>> diff --git a/gpsutils.c b/gpsutils.c
>> index 1564131..7dda32a 100644
>> --- a/gpsutils.c
>> +++ b/gpsutils.c
>> @@ -352,7 +352,7 @@ timestamp_t iso8601_to_unix( /address@hidden@*/ char 
>> *isotime)
>>        usec = strtod(dp, NULL);
>>     else
>>        usec = 0;
>> -    return (timestamp_t)mktime(&tm) - timezone + usec;
>> +    return (timestamp_t)timegm(&tm) + usec;
>> #else
>>     double usec = 0;
> 
> That patch would reintroduce a glibc dependency, which we're trying to avoid.

> The timezone global is an ugly but standardized feature of the POSIX/SuS API,
> supposed to be set after tzset(3).  Does FreeBSD really not have it?  Perhaps
> there's a feature macro you need to enable.

I couldn't see it, even better there is this in time.h...
#if __BSD_VISIBLE
char *timezone(int, int);       /* XXX XSI conflict */
void tzsetwall(void);
time_t timelocal(struct tm * const);
time_t timegm(struct tm * const);
#endif /* __BSD_VISIBLE */

So I guess the only way is "if BSD/OSX use timegm else use timezone".

There is a bug filed for it in FreeBSD 
https://lists.freebsd.org/pipermail/freebsd-standards/2011-January/002111.html 
but the reply from Garrett suggests it's not likely to be fixed.

--
Daniel O'Connor
"The nice thing about standards is that there
are so many of them to choose from."
 -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C




reply via email to

[Prev in Thread] Current Thread [Next in Thread]