Re: [HACKERS] Date/time on glibc2 linux

From: Oleg Broytmann <phd(at)sun(dot)med(dot)ru>
To: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Date/time on glibc2 linux
Date: 1998-12-09 18:33:28
Message-ID: Pine.SOL2.3.96.SK.981209212753.9319A-100000@sun.med.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

On Wed, 9 Dec 1998, Thomas G. Lockhart wrote:

> > Another problem I have - I cannot recompile postgres with DATEDEBUG
> > defined in config.h - I got the error:
> <snip>
>
> These don't appear to be related. However, I usually just (slightly)

I am sure this is related. When I edited config.h and commented out
DATEDEBUG the sources compiled just fine.

> edit the src/backend/utils/adt/Makefile to add in
> CFLAGS+= -DDATEDEBUG

Well, I'll try this.

> since it is a symbol which afaik only affects files in that directory,
> and should not be kept in after you are finished.

> Do you have any test cases *other* than the date->datetime conversion
> example? If you don't then we should probably be looking for a very
> local problem, not a system-wide problem. otoh I have a hard time
> picturing how this could not be a system-wide problem, given that I see
> no problems on the same test case on gcc/libc5 systems.

Any use for daylight or tzname or timezone (global vars) produces
incorrect results. Again, test program is very simple:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char **argv) {
char strf_buf[100];
time_t today_t;
struct tm * today;

memset(strf_buf, 0, 99);
today_t = time(NULL);
today = localtime(&today_t);
strftime(strf_buf, 100, "%Z", today);
printf("%s\n", strf_buf);

/* In Moscow I expect MSK/MSD/1/10800 */
printf("%s\n%s\n%d\n%ld\n", tzname[0], tzname[1], daylight, timezone);

return 0;
}

It looks like glibc2 defines these vars incorrectly. Correct values are
in struct tm (including tmzone and gmtoff).
Do you think it is local problem? I am pretty sure it is "system-wide".

Oleg.
----
Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/
Programmers don't die, they just GOSUB without RETURN.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleg Bartunov 1998-12-09 18:47:12 Re: [HACKERS] problem compiling with egcs 1.1.1
Previous Message Thomas G. Lockhart 1998-12-09 18:25:02 Re: [HACKERS] Date/time on glibc2 linux