1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-17 17:02:08 +03:00

Change ordering of HAVE_TM_ZONE and HAVE_INT_TIMEZONE code blocks

to give HAVE_TM_ZONE priority. This fixes glibc2 machines and any other
 machine which passes both tests in configure.
Repair HAVE_TM_ZONE code which stuffs tm structure with date type values.
 Same problems as were originally there before v6.1, but never noticed.
Thanks to Oleg for nagging :)
This commit is contained in:
Thomas G. Lockhart
1998-12-31 16:30:59 +00:00
parent 2d74bf8843
commit 4d56dbd678
3 changed files with 76 additions and 52 deletions

View File

@ -4,7 +4,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nabstime.c,v 1.50 1998/12/15 15:28:57 scrappy Exp $
* $Id: nabstime.c,v 1.51 1998/12/31 16:30:59 thomas Exp $
*
*/
#include <stdio.h>
@ -57,7 +57,7 @@ GetCurrentAbsoluteTime(void)
if (!HasCTZSet)
{
#ifdef USE_POSIX_TIME
#ifdef HAVE_TM_ZONE
#if defined(HAVE_TM_ZONE)
tm = localtime(&now);
CTimeZone = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
@ -86,9 +86,8 @@ GetCurrentAbsoluteTime(void)
CTimeZone = tb.timezone * 60;
CDayLight = (tb.dstflag != 0);
/*
* XXX does this work to get the local timezone string in V7? -
* tgl 97/03/18
/* XXX does this work to get the local timezone string in V7?
* - tgl 97/03/18
*/
strftime(CTZName, MAXTZLEN, "%Z", localtime(&now));
#endif
@ -136,14 +135,14 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
#endif
#if defined(DATEDEBUG)
#if (! defined(HAVE_TM_ZONE)) && defined(HAVE_INT_TIMEZONE)
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s %s dst=%d\n",
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, tx->tm_sec,
tzname[0], tzname[1], tx->tm_isdst);
#else
#if defined(HAVE_TM_ZONE)
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s dst=%d\n",
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, tx->tm_sec,
tx->tm_zone, tx->tm_isdst);
#elif defined(HAVE_INT_TIMEZONE)
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s %s dst=%d\n",
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, tx->tm_sec,
tzname[0], tzname[1], tx->tm_isdst);
#endif
#endif
@ -157,7 +156,7 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
tm->tm_sec = tx->tm_sec;
tm->tm_isdst = tx->tm_isdst;
#ifdef HAVE_TM_ZONE
#if defined(HAVE_TM_ZONE)
tm->tm_gmtoff = tx->tm_gmtoff;
tm->tm_zone = tx->tm_zone;
@ -171,7 +170,7 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
*tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
if (tzn != NULL)
strcpy(tzn, tzname[tm->tm_isdst]);
#else /* !HAVE_INT_TIMEZONE */
#else
#error POSIX time support is broken
#endif
#else /* ! USE_POSIX_TIME */