mirror of https://github.com/postgres/postgres
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:
parent
2d74bf8843
commit
4d56dbd678
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.25 1998/09/01 03:25:54 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.26 1998/12/31 16:30:56 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -357,14 +357,18 @@ date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn)
|
||||||
|
|
||||||
/* convert to system time */
|
/* convert to system time */
|
||||||
utime = ((dateVal + (date2j(2000, 1, 1) - date2j(1970, 1, 1))) * 86400);
|
utime = ((dateVal + (date2j(2000, 1, 1) - date2j(1970, 1, 1))) * 86400);
|
||||||
utime += (12 * 60 * 60);/* rotate to noon to get the right day in
|
/* rotate to noon to get the right day in time zone */
|
||||||
* time zone */
|
utime += (12 * 60 * 60);
|
||||||
|
|
||||||
#ifdef USE_POSIX_TIME
|
#ifdef USE_POSIX_TIME
|
||||||
tx = localtime(&utime);
|
tx = localtime(&utime);
|
||||||
|
|
||||||
#ifdef DATEDEBUG
|
#ifdef DATEDEBUG
|
||||||
#ifdef HAVE_INT_TIMEZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
|
printf("date2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
|
||||||
|
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, (double) tm->tm_sec,
|
||||||
|
tx->tm_zone, tx->tm_isdst);
|
||||||
|
#elif defined(HAVE_INT_TIMEZONE)
|
||||||
printf("date2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
|
printf("date2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
|
||||||
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, (double) tm->tm_sec,
|
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, (double) tm->tm_sec,
|
||||||
tzname[0], tzname[1], tx->tm_isdst);
|
tzname[0], tzname[1], tx->tm_isdst);
|
||||||
|
@ -375,21 +379,21 @@ date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn)
|
||||||
tm->tm_mday = tx->tm_mday;
|
tm->tm_mday = tx->tm_mday;
|
||||||
tm->tm_isdst = tx->tm_isdst;
|
tm->tm_isdst = tx->tm_isdst;
|
||||||
|
|
||||||
#ifdef HAVE_INT_TIMEZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
*tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
|
|
||||||
if (tzn != NULL)
|
|
||||||
*tzn = tzname[(tm->tm_isdst > 0)];
|
|
||||||
|
|
||||||
#else /* !HAVE_INT_TIMEZONE */
|
|
||||||
tm->tm_gmtoff = tx->tm_gmtoff;
|
tm->tm_gmtoff = tx->tm_gmtoff;
|
||||||
tm->tm_zone = tx->tm_zone;
|
tm->tm_zone = tx->tm_zone;
|
||||||
|
|
||||||
*tzp = (tm->tm_isdst ? (tm->tm_gmtoff - 3600) : tm->tm_gmtoff); /* tm_gmtoff is
|
/* tm_gmtoff is Sun/DEC-ism */
|
||||||
* Sun/DEC-ism */
|
*tzp = -(tm->tm_gmtoff);
|
||||||
if (tzn != NULL)
|
if (tzn != NULL)
|
||||||
*tzn = tm->tm_zone;
|
*tzn = (char *)tm->tm_zone;
|
||||||
|
#elif defined(HAVE_INT_TIMEZONE)
|
||||||
|
*tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
|
||||||
|
if (tzn != NULL)
|
||||||
|
*tzn = tzname[(tm->tm_isdst > 0)];
|
||||||
|
#else
|
||||||
|
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* !USE_POSIX_TIME */
|
#else /* !USE_POSIX_TIME */
|
||||||
*tzp = CTimeZone; /* V7 conventions; don't know timezone? */
|
*tzp = CTimeZone; /* V7 conventions; don't know timezone? */
|
||||||
if (tzn != NULL)
|
if (tzn != NULL)
|
||||||
|
@ -411,6 +415,18 @@ date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn)
|
||||||
*tzn = NULL;
|
*tzn = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DATEDEBUG
|
||||||
|
#if defined(HAVE_TM_ZONE)
|
||||||
|
printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s) dst=%d\n",
|
||||||
|
tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, (double) tm->tm_sec,
|
||||||
|
*tzp, tm->tm_zone, tm->tm_isdst);
|
||||||
|
#elif defined(HAVE_INT_TIMEZONE)
|
||||||
|
printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s %s) dst=%d\n",
|
||||||
|
tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, (double) tm->tm_sec,
|
||||||
|
*tzp, tzname[0], tzname[1], tm->tm_isdst);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} /* date2tm() */
|
} /* date2tm() */
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.59 1998/10/08 18:30:07 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.60 1998/12/31 16:30:57 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -1454,11 +1454,12 @@ datetime_trunc(text *units, DateTime *datetime)
|
||||||
tm->tm_year += 1900;
|
tm->tm_year += 1900;
|
||||||
tm->tm_mon += 1;
|
tm->tm_mon += 1;
|
||||||
|
|
||||||
#ifdef HAVE_INT_TIMEZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
tz = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
|
|
||||||
|
|
||||||
#else /* !HAVE_INT_TIMEZONE */
|
|
||||||
tz = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
|
tz = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
|
||||||
|
#elif defined(HAVE_INT_TIMEZONE)
|
||||||
|
tz = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
|
||||||
|
#else
|
||||||
|
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* !USE_POSIX_TIME */
|
#else /* !USE_POSIX_TIME */
|
||||||
|
@ -2414,16 +2415,17 @@ datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
|
||||||
#ifdef USE_POSIX_TIME
|
#ifdef USE_POSIX_TIME
|
||||||
tx = localtime(&utime);
|
tx = localtime(&utime);
|
||||||
#ifdef DATEDEBUG
|
#ifdef DATEDEBUG
|
||||||
#ifdef HAVE_INT_TIMEZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
|
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
|
||||||
|
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, sec,
|
||||||
|
tx->tm_zone, tx->tm_isdst);
|
||||||
|
#elif defined(HAVE_INT_TIMEZONE)
|
||||||
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
|
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
|
||||||
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, sec,
|
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, sec,
|
||||||
tzname[0], tzname[1], tx->tm_isdst);
|
tzname[0], tzname[1], tx->tm_isdst);
|
||||||
#else
|
#else
|
||||||
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
|
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
|
||||||
tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, sec,
|
|
||||||
tx->tm_zone, tx->tm_isdst);
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#endif
|
#endif
|
||||||
tm->tm_year = tx->tm_year + 1900;
|
tm->tm_year = tx->tm_year + 1900;
|
||||||
tm->tm_mon = tx->tm_mon + 1;
|
tm->tm_mon = tx->tm_mon + 1;
|
||||||
|
@ -2442,18 +2444,19 @@ datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
|
||||||
#endif
|
#endif
|
||||||
tm->tm_isdst = tx->tm_isdst;
|
tm->tm_isdst = tx->tm_isdst;
|
||||||
|
|
||||||
#ifdef HAVE_INT_TIMEZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
*tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
|
|
||||||
if (tzn != NULL)
|
|
||||||
*tzn = tzname[(tm->tm_isdst > 0)];
|
|
||||||
|
|
||||||
#else /* !HAVE_INT_TIMEZONE */
|
|
||||||
tm->tm_gmtoff = tx->tm_gmtoff;
|
tm->tm_gmtoff = tx->tm_gmtoff;
|
||||||
tm->tm_zone = tx->tm_zone;
|
tm->tm_zone = tx->tm_zone;
|
||||||
|
|
||||||
*tzp = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
|
*tzp = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
|
||||||
if (tzn != NULL)
|
if (tzn != NULL)
|
||||||
*tzn = tm->tm_zone;
|
*tzn = (char *)tm->tm_zone;
|
||||||
|
#elif defined(HAVE_INT_TIMEZONE)
|
||||||
|
*tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
|
||||||
|
if (tzn != NULL)
|
||||||
|
*tzn = tzname[(tm->tm_isdst > 0)];
|
||||||
|
#else
|
||||||
|
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* !USE_POSIX_TIME */
|
#else /* !USE_POSIX_TIME */
|
||||||
|
@ -2488,7 +2491,10 @@ datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
|
||||||
|
|
||||||
#ifdef DATEDEBUG
|
#ifdef DATEDEBUG
|
||||||
#ifdef USE_POSIX_TIME
|
#ifdef USE_POSIX_TIME
|
||||||
#ifdef HAVE_INT_TIMEZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
|
printf("datetime2tm- timezone is %s; offset is %d\n",
|
||||||
|
tm->tm_zone, ((tzp != NULL) ? *tzp : 0));
|
||||||
|
#elif defined(HAVE_INT_TIMEZONE)
|
||||||
printf("datetime2tm- timezone is %s; offset is %d (%d); daylight is %d\n",
|
printf("datetime2tm- timezone is %s; offset is %d (%d); daylight is %d\n",
|
||||||
tzname[tm->tm_isdst != 0], ((tzp != NULL) ? *tzp : 0), CTimeZone, CDayLight);
|
tzname[tm->tm_isdst != 0], ((tzp != NULL) ? *tzp : 0), CTimeZone, CDayLight);
|
||||||
#endif
|
#endif
|
||||||
|
@ -3034,11 +3040,12 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
||||||
tm->tm_year += 1900;
|
tm->tm_year += 1900;
|
||||||
tm->tm_mon += 1;
|
tm->tm_mon += 1;
|
||||||
|
|
||||||
#ifdef HAVE_INT_TIMEZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
*tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
|
|
||||||
|
|
||||||
#else /* !HAVE_INT_TIMEZONE */
|
|
||||||
*tzp = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
|
*tzp = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
|
||||||
|
#elif defined(HAVE_INT_TIMEZONE)
|
||||||
|
*tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
|
||||||
|
#else
|
||||||
|
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* !USE_POSIX_TIME */
|
#else /* !USE_POSIX_TIME */
|
||||||
|
@ -4104,12 +4111,14 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
|
||||||
|
|
||||||
#ifdef DATEDEBUG
|
#ifdef DATEDEBUG
|
||||||
#ifdef USE_POSIX_TIME
|
#ifdef USE_POSIX_TIME
|
||||||
#ifdef HAVE_INT_TIMEZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
|
printf("EncodeDateTime- timezone is %s (%s); offset is %ld (%d); daylight is %d (%d)\n",
|
||||||
|
*tzn, tm->tm_zone, (-tm->tm_gmtoff), CTimeZone, tm->tm_isdst, CDayLight);
|
||||||
|
#elif defined(HAVE_INT_TIMEZONE)
|
||||||
printf("EncodeDateTime- timezone is %s (%s); offset is %d (%d); daylight is %d (%d)\n",
|
printf("EncodeDateTime- timezone is %s (%s); offset is %d (%d); daylight is %d (%d)\n",
|
||||||
*tzn, tzname[0], *tzp, CTimeZone, tm->tm_isdst, CDayLight);
|
*tzn, tzname[0], *tzp, CTimeZone, tm->tm_isdst, CDayLight);
|
||||||
#else
|
#else
|
||||||
printf("EncodeDateTime- timezone is %s (%s); offset is %ld (%d); daylight is %d (%d)\n",
|
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
|
||||||
*tzn, tm->tm_zone, (-tm->tm_gmtoff), CTimeZone, tm->tm_isdst, CDayLight);
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
printf("EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n",
|
printf("EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* 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>
|
#include <stdio.h>
|
||||||
|
@ -57,7 +57,7 @@ GetCurrentAbsoluteTime(void)
|
||||||
if (!HasCTZSet)
|
if (!HasCTZSet)
|
||||||
{
|
{
|
||||||
#ifdef USE_POSIX_TIME
|
#ifdef USE_POSIX_TIME
|
||||||
#ifdef HAVE_TM_ZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
tm = localtime(&now);
|
tm = localtime(&now);
|
||||||
|
|
||||||
CTimeZone = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
|
CTimeZone = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
|
||||||
|
@ -86,9 +86,8 @@ GetCurrentAbsoluteTime(void)
|
||||||
CTimeZone = tb.timezone * 60;
|
CTimeZone = tb.timezone * 60;
|
||||||
CDayLight = (tb.dstflag != 0);
|
CDayLight = (tb.dstflag != 0);
|
||||||
|
|
||||||
/*
|
/* XXX does this work to get the local timezone string in V7?
|
||||||
* XXX does this work to get the local timezone string in V7? -
|
* - tgl 97/03/18
|
||||||
* tgl 97/03/18
|
|
||||||
*/
|
*/
|
||||||
strftime(CTZName, MAXTZLEN, "%Z", localtime(&now));
|
strftime(CTZName, MAXTZLEN, "%Z", localtime(&now));
|
||||||
#endif
|
#endif
|
||||||
|
@ -136,14 +135,14 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DATEDEBUG)
|
#if defined(DATEDEBUG)
|
||||||
#if (! defined(HAVE_TM_ZONE)) && defined(HAVE_INT_TIMEZONE)
|
#if defined(HAVE_TM_ZONE)
|
||||||
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
|
|
||||||
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s dst=%d\n",
|
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_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, tx->tm_sec,
|
||||||
tx->tm_zone, tx->tm_isdst);
|
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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -157,7 +156,7 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
|
||||||
tm->tm_sec = tx->tm_sec;
|
tm->tm_sec = tx->tm_sec;
|
||||||
tm->tm_isdst = tx->tm_isdst;
|
tm->tm_isdst = tx->tm_isdst;
|
||||||
|
|
||||||
#ifdef HAVE_TM_ZONE
|
#if defined(HAVE_TM_ZONE)
|
||||||
tm->tm_gmtoff = tx->tm_gmtoff;
|
tm->tm_gmtoff = tx->tm_gmtoff;
|
||||||
tm->tm_zone = tx->tm_zone;
|
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);
|
*tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
|
||||||
if (tzn != NULL)
|
if (tzn != NULL)
|
||||||
strcpy(tzn, tzname[tm->tm_isdst]);
|
strcpy(tzn, tzname[tm->tm_isdst]);
|
||||||
#else /* !HAVE_INT_TIMEZONE */
|
#else
|
||||||
#error POSIX time support is broken
|
#error POSIX time support is broken
|
||||||
#endif
|
#endif
|
||||||
#else /* ! USE_POSIX_TIME */
|
#else /* ! USE_POSIX_TIME */
|
||||||
|
|
Loading…
Reference in New Issue