[BUG] GTimeZone broken on Windows

Lubomir I. Ivanov neolit123 at gmail.com
Wed Feb 27 09:47:08 PST 2013


On 27 February 2013 19:13, Dirk Hohndel <dirk at hohndel.org> wrote:
> Linus Torvalds <torvalds at linux-foundation.org> writes:
>
>> On Wed, Feb 27, 2013 at 8:05 AM, Dirk Hohndel <dirk at hohndel.org> wrote:
>>>
>>> That is a MASSIVE undertaking. Time zones are insanely complicated and
>>> annoying. And they change all the time. I'd much rather find a library
>>> that is out there, is maintained, and works.
>>
>> It's called "standard C library".
>>
>> Dicking around with timezones is stupid. Don't do it. Just do what
>> info.c already does:
>>
>>                 time_t now;
>>                 struct timeval tv;
>>
>>                 gettimeofday(&tv, NULL);
>>                 now = tv.tv_sec;
>>                 time = localtime(&now);
>>
>> and you're done. Really. None of this idiotic gliib crap. glib
>> interfaces are almost universally stupid.
>>
>> Now you can turn it into our own interface format by using our very
>> own "utc_mktime()", which is rather simple and just ignores the
>> timezone information in 'struct tm'.
>
> I think sending a patch would have been less typing :-)
>

just sent a patch:
[PATCH] Planner: use time.h and utc_mktime() to retrive the current time (no TZ)

would this work? i seem to be getting correct values with it on both
windows and linux.

static timestamp_t current_time_notz(void)
{
	time_t now = time(NULL);
	struct tm *local = localtime(&now);
	return utc_mktime(local);
}

lubomir
--


More information about the subsurface mailing list