Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4d56dbd

Browse files
author
Thomas G. Lockhart
committed
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 :)
1 parent2d74bf8 commit4d56dbd

File tree

3 files changed

+76
-52
lines changed

3 files changed

+76
-52
lines changed

‎src/backend/utils/adt/datetime.c

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.25 1998/09/01 03:25:54 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.26 1998/12/31 16:30:56 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -339,7 +339,7 @@ abstime_date(AbsoluteTime abstime)
339339
*and then convert again to try to get the time zones correct.
340340
*/
341341
staticint
342-
date2tm(DateADTdateVal,int*tzp,structtm*tm,double*fsec,char**tzn)
342+
date2tm(DateADTdateVal,int*tzp,structtm*tm,double*fsec,char**tzn)
343343
{
344344
structtm*tx;
345345
time_tutime;
@@ -357,14 +357,18 @@ date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn)
357357

358358
/* convert to system time */
359359
utime= ((dateVal+ (date2j(2000,1,1)-date2j(1970,1,1)))*86400);
360-
utime+= (12*60*60);/* rotate to noon to get the right day in
361-
* time zone */
360+
/* rotate to noon to get the right day in time zone */
361+
utime+= (12*60*60);
362362

363363
#ifdefUSE_POSIX_TIME
364364
tx=localtime(&utime);
365365

366366
#ifdefDATEDEBUG
367-
#ifdefHAVE_INT_TIMEZONE
367+
#if defined(HAVE_TM_ZONE)
368+
printf("date2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
369+
tx->tm_year,tx->tm_mon,tx->tm_mday,tx->tm_hour,tx->tm_min, (double)tm->tm_sec,
370+
tx->tm_zone,tx->tm_isdst);
371+
#elif defined(HAVE_INT_TIMEZONE)
368372
printf("date2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
369373
tx->tm_year,tx->tm_mon,tx->tm_mday,tx->tm_hour,tx->tm_min, (double)tm->tm_sec,
370374
tzname[0],tzname[1],tx->tm_isdst);
@@ -375,21 +379,21 @@ date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn)
375379
tm->tm_mday=tx->tm_mday;
376380
tm->tm_isdst=tx->tm_isdst;
377381

378-
#ifdefHAVE_INT_TIMEZONE
379-
*tzp= (tm->tm_isdst ? (timezone-3600) :timezone);
380-
if (tzn!=NULL)
381-
*tzn=tzname[(tm->tm_isdst>0)];
382-
383-
#else/* !HAVE_INT_TIMEZONE */
382+
#if defined(HAVE_TM_ZONE)
384383
tm->tm_gmtoff=tx->tm_gmtoff;
385384
tm->tm_zone=tx->tm_zone;
386385

387-
*tzp= (tm->tm_isdst ? (tm->tm_gmtoff-3600) :tm->tm_gmtoff);/* tm_gmtoff is
388-
* Sun/DEC-ism */
386+
/* tm_gmtoff is Sun/DEC-ism */
387+
*tzp=-(tm->tm_gmtoff);
388+
if (tzn!=NULL)
389+
*tzn= (char*)tm->tm_zone;
390+
#elif defined(HAVE_INT_TIMEZONE)
391+
*tzp= (tm->tm_isdst ? (timezone-3600) :timezone);
389392
if (tzn!=NULL)
390-
*tzn=tm->tm_zone;
393+
*tzn=tzname[(tm->tm_isdst>0)];
394+
#else
395+
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
391396
#endif
392-
393397
#else/* !USE_POSIX_TIME */
394398
*tzp=CTimeZone;/* V7 conventions; don't know timezone? */
395399
if (tzn!=NULL)
@@ -411,6 +415,18 @@ date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn)
411415
*tzn=NULL;
412416
}
413417

418+
#ifdefDATEDEBUG
419+
#if defined(HAVE_TM_ZONE)
420+
printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s) dst=%d\n",
421+
tm->tm_year,tm->tm_mon,tm->tm_mday,tm->tm_hour,tm->tm_min, (double)tm->tm_sec,
422+
*tzp,tm->tm_zone,tm->tm_isdst);
423+
#elif defined(HAVE_INT_TIMEZONE)
424+
printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s %s) dst=%d\n",
425+
tm->tm_year,tm->tm_mon,tm->tm_mday,tm->tm_hour,tm->tm_min, (double)tm->tm_sec,
426+
*tzp,tzname[0],tzname[1],tm->tm_isdst);
427+
#endif
428+
#endif
429+
414430
return0;
415431
}/* date2tm() */
416432

‎src/backend/utils/adt/dt.c

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.59 1998/10/08 18:30:07 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.60 1998/12/31 16:30:57 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1454,11 +1454,12 @@ datetime_trunc(text *units, DateTime *datetime)
14541454
tm->tm_year+=1900;
14551455
tm->tm_mon+=1;
14561456

1457-
#ifdefHAVE_INT_TIMEZONE
1458-
tz= ((tm->tm_isdst>0) ? (timezone-3600) :timezone);
1459-
1460-
#else/* !HAVE_INT_TIMEZONE */
1457+
#if defined(HAVE_TM_ZONE)
14611458
tz=-(tm->tm_gmtoff);/* tm_gmtoff is Sun/DEC-ism */
1459+
#elif defined(HAVE_INT_TIMEZONE)
1460+
tz= ((tm->tm_isdst>0) ? (timezone-3600) :timezone);
1461+
#else
1462+
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
14621463
#endif
14631464

14641465
#else/* !USE_POSIX_TIME */
@@ -2414,16 +2415,17 @@ datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
24142415
#ifdefUSE_POSIX_TIME
24152416
tx=localtime(&utime);
24162417
#ifdefDATEDEBUG
2417-
#ifdefHAVE_INT_TIMEZONE
2418+
#if defined(HAVE_TM_ZONE)
2419+
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
2420+
tx->tm_year,tx->tm_mon,tx->tm_mday,tx->tm_hour,tx->tm_min,sec,
2421+
tx->tm_zone,tx->tm_isdst);
2422+
#elif defined(HAVE_INT_TIMEZONE)
24182423
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
24192424
tx->tm_year,tx->tm_mon,tx->tm_mday,tx->tm_hour,tx->tm_min,sec,
24202425
tzname[0],tzname[1],tx->tm_isdst);
24212426
#else
2422-
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
2423-
tx->tm_year,tx->tm_mon,tx->tm_mday,tx->tm_hour,tx->tm_min,sec,
2424-
tx->tm_zone,tx->tm_isdst);
2427+
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
24252428
#endif
2426-
#else
24272429
#endif
24282430
tm->tm_year=tx->tm_year+1900;
24292431
tm->tm_mon=tx->tm_mon+1;
@@ -2442,18 +2444,19 @@ datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
24422444
#endif
24432445
tm->tm_isdst=tx->tm_isdst;
24442446

2445-
#ifdefHAVE_INT_TIMEZONE
2446-
*tzp= (tm->tm_isdst ? (timezone-3600) :timezone);
2447-
if (tzn!=NULL)
2448-
*tzn=tzname[(tm->tm_isdst>0)];
2449-
2450-
#else/* !HAVE_INT_TIMEZONE */
2447+
#if defined(HAVE_TM_ZONE)
24512448
tm->tm_gmtoff=tx->tm_gmtoff;
24522449
tm->tm_zone=tx->tm_zone;
24532450

24542451
*tzp=-(tm->tm_gmtoff);/* tm_gmtoff is Sun/DEC-ism */
24552452
if (tzn!=NULL)
2456-
*tzn=tm->tm_zone;
2453+
*tzn= (char*)tm->tm_zone;
2454+
#elif defined(HAVE_INT_TIMEZONE)
2455+
*tzp= (tm->tm_isdst ? (timezone-3600) :timezone);
2456+
if (tzn!=NULL)
2457+
*tzn=tzname[(tm->tm_isdst>0)];
2458+
#else
2459+
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
24572460
#endif
24582461

24592462
#else/* !USE_POSIX_TIME */
@@ -2488,7 +2491,10 @@ datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
24882491

24892492
#ifdefDATEDEBUG
24902493
#ifdefUSE_POSIX_TIME
2491-
#ifdefHAVE_INT_TIMEZONE
2494+
#if defined(HAVE_TM_ZONE)
2495+
printf("datetime2tm- timezone is %s; offset is %d\n",
2496+
tm->tm_zone, ((tzp!=NULL) ?*tzp :0));
2497+
#elif defined(HAVE_INT_TIMEZONE)
24922498
printf("datetime2tm- timezone is %s; offset is %d (%d); daylight is %d\n",
24932499
tzname[tm->tm_isdst!=0], ((tzp!=NULL) ?*tzp :0),CTimeZone,CDayLight);
24942500
#endif
@@ -3034,11 +3040,12 @@ DecodeDateTime(char **field, int *ftype, int nf,
30343040
tm->tm_year+=1900;
30353041
tm->tm_mon+=1;
30363042

3037-
#ifdefHAVE_INT_TIMEZONE
3038-
*tzp= ((tm->tm_isdst>0) ? (timezone-3600) :timezone);
3039-
3040-
#else/* !HAVE_INT_TIMEZONE */
3043+
#if defined(HAVE_TM_ZONE)
30413044
*tzp=-(tm->tm_gmtoff);/* tm_gmtoff is Sun/DEC-ism */
3045+
#elif defined(HAVE_INT_TIMEZONE)
3046+
*tzp= ((tm->tm_isdst>0) ? (timezone-3600) :timezone);
3047+
#else
3048+
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
30423049
#endif
30433050

30443051
#else/* !USE_POSIX_TIME */
@@ -4104,12 +4111,14 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
41044111

41054112
#ifdefDATEDEBUG
41064113
#ifdefUSE_POSIX_TIME
4107-
#ifdefHAVE_INT_TIMEZONE
4114+
#if defined(HAVE_TM_ZONE)
4115+
printf("EncodeDateTime- timezone is %s (%s); offset is %ld (%d); daylight is %d (%d)\n",
4116+
*tzn,tm->tm_zone, (-tm->tm_gmtoff),CTimeZone,tm->tm_isdst,CDayLight);
4117+
#elif defined(HAVE_INT_TIMEZONE)
41084118
printf("EncodeDateTime- timezone is %s (%s); offset is %d (%d); daylight is %d (%d)\n",
41094119
*tzn,tzname[0],*tzp,CTimeZone,tm->tm_isdst,CDayLight);
41104120
#else
4111-
printf("EncodeDateTime- timezone is %s (%s); offset is %ld (%d); daylight is %d (%d)\n",
4112-
*tzn,tm->tm_zone, (-tm->tm_gmtoff),CTimeZone,tm->tm_isdst,CDayLight);
4121+
#error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
41134122
#endif
41144123
#else
41154124
printf("EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n",

‎src/backend/utils/adt/nabstime.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 1994, Regents of the University of California
66
*
7-
* $Id: nabstime.c,v 1.50 1998/12/15 15:28:57 scrappy Exp $
7+
* $Id: nabstime.c,v 1.51 1998/12/31 16:30:59 thomas Exp $
88
*
99
*/
1010
#include<stdio.h>
@@ -57,7 +57,7 @@ GetCurrentAbsoluteTime(void)
5757
if (!HasCTZSet)
5858
{
5959
#ifdefUSE_POSIX_TIME
60-
#ifdefHAVE_TM_ZONE
60+
#if defined(HAVE_TM_ZONE)
6161
tm=localtime(&now);
6262

6363
CTimeZone=-tm->tm_gmtoff;/* tm_gmtoff is Sun/DEC-ism */
@@ -86,9 +86,8 @@ GetCurrentAbsoluteTime(void)
8686
CTimeZone=tb.timezone*60;
8787
CDayLight= (tb.dstflag!=0);
8888

89-
/*
90-
* XXX does this work to get the local timezone string in V7? -
91-
* tgl 97/03/18
89+
/* XXX does this work to get the local timezone string in V7?
90+
* - tgl 97/03/18
9291
*/
9392
strftime(CTZName,MAXTZLEN,"%Z",localtime(&now));
9493
#endif
@@ -136,14 +135,14 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
136135
#endif
137136

138137
#if defined(DATEDEBUG)
139-
#if (! defined(HAVE_TM_ZONE))&& defined(HAVE_INT_TIMEZONE)
140-
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s %s dst=%d\n",
141-
tx->tm_year,tx->tm_mon,tx->tm_mday,tx->tm_hour,tx->tm_min,tx->tm_sec,
142-
tzname[0],tzname[1],tx->tm_isdst);
143-
#else
138+
#if defined(HAVE_TM_ZONE)
144139
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s dst=%d\n",
145140
tx->tm_year,tx->tm_mon,tx->tm_mday,tx->tm_hour,tx->tm_min,tx->tm_sec,
146141
tx->tm_zone,tx->tm_isdst);
142+
#elif defined(HAVE_INT_TIMEZONE)
143+
printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s %s dst=%d\n",
144+
tx->tm_year,tx->tm_mon,tx->tm_mday,tx->tm_hour,tx->tm_min,tx->tm_sec,
145+
tzname[0],tzname[1],tx->tm_isdst);
147146
#endif
148147
#endif
149148

@@ -157,7 +156,7 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
157156
tm->tm_sec=tx->tm_sec;
158157
tm->tm_isdst=tx->tm_isdst;
159158

160-
#ifdefHAVE_TM_ZONE
159+
#if defined(HAVE_TM_ZONE)
161160
tm->tm_gmtoff=tx->tm_gmtoff;
162161
tm->tm_zone=tx->tm_zone;
163162

@@ -171,7 +170,7 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
171170
*tzp= (tm->tm_isdst ? (timezone-3600) :timezone);
172171
if (tzn!=NULL)
173172
strcpy(tzn,tzname[tm->tm_isdst]);
174-
#else/* !HAVE_INT_TIMEZONE */
173+
#else
175174
#error POSIX time support is broken
176175
#endif
177176
#else/* ! USE_POSIX_TIME */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp