77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.46 1998/10/08 18:30:09 momjian Exp $
10+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.47 1998/12/13 23:34:17 thomas Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -61,23 +61,31 @@ GetCurrentAbsoluteTime(void)
6161if (!HasCTZSet )
6262{
6363#ifdef USE_POSIX_TIME
64- #if defined(HAVE_TZSET )&& defined(HAVE_INT_TIMEZONE )
65- tm = localtime (& now );
66-
67- CDayLight = tm -> tm_isdst ;
68- CTimeZone = (tm -> tm_isdst ? (timezone - 3600 ) :timezone );
69- strcpy (CTZName ,tzname [tm -> tm_isdst ]);
70- #else /* !HAVE_TZSET */
64+ #ifdef HAVE_TM_ZONE
7165tm = localtime (& now );
7266
7367CTimeZone = - tm -> tm_gmtoff ;/* tm_gmtoff is Sun/DEC-ism */
7468CDayLight = (tm -> tm_isdst > 0 );
7569
70+ #if 0
7671/*
7772 * XXX is there a better way to get local timezone string w/o
7873 * tzname? - tgl 97/03/18
7974 */
8075strftime (CTZName ,MAXTZLEN ,"%Z" ,tm );
76+ #endif
77+ /* XXX FreeBSD man pages indicate that this should work - thomas 1998-12-12 */
78+ if (tzn != NULL )
79+ strcpy (tzn ,tm -> tm_zone );
80+
81+ #elif defined(HAVE_INT_TIMEZONE )
82+ tm = localtime (& now );
83+
84+ CDayLight = tm -> tm_isdst ;
85+ CTimeZone = (tm -> tm_isdst ? (timezone - 3600 ) :timezone );
86+ strcpy (CTZName ,tzname [tm -> tm_isdst ]);
87+ #else
88+ #error USE_POSIX_TIME defined but no time zone available
8189#endif
8290#else /* ! USE_POSIX_TIME */
8391CTimeZone = tb .timezone * 60 ;
@@ -133,7 +141,7 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
133141#endif
134142
135143#if defined(DATEDEBUG )
136- #if defined(HAVE_INT_TIMEZONE )
144+ #if (! defined( HAVE_TM_ZONE )) && defined(HAVE_INT_TIMEZONE )
137145printf ("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s %s dst=%d\n" ,
138146tx -> tm_year ,tx -> tm_mon ,tx -> tm_mday ,tx -> tm_hour ,tx -> tm_min ,tx -> tm_sec ,
139147tzname [0 ],tzname [1 ],tx -> tm_isdst );
@@ -154,12 +162,7 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
154162tm -> tm_sec = tx -> tm_sec ;
155163tm -> tm_isdst = tx -> tm_isdst ;
156164
157- #ifdef HAVE_INT_TIMEZONE
158- if (tzp != NULL )
159- * tzp = (tm -> tm_isdst ? (timezone - 3600 ) :timezone );
160- if (tzn != NULL )
161- strcpy (tzn ,tzname [tm -> tm_isdst ]);
162- #else /* !HAVE_INT_TIMEZONE */
165+ #ifdef HAVE_TM_ZONE
163166tm -> tm_gmtoff = tx -> tm_gmtoff ;
164167tm -> tm_zone = tx -> tm_zone ;
165168
@@ -168,6 +171,13 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
168171/* XXX FreeBSD man pages indicate that this should work - tgl 97/04/23 */
169172if (tzn != NULL )
170173strcpy (tzn ,tm -> tm_zone );
174+ #elif defined(HAVE_INT_TIMEZONE )
175+ if (tzp != NULL )
176+ * tzp = (tm -> tm_isdst ? (timezone - 3600 ) :timezone );
177+ if (tzn != NULL )
178+ strcpy (tzn ,tzname [tm -> tm_isdst ]);
179+ #else /* !HAVE_INT_TIMEZONE */
180+ #error POSIX time support is broken
171181#endif
172182#else /* ! USE_POSIX_TIME */
173183if (tzp != NULL )