summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/formatting.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-05-03 22:53:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-05-03 22:53:07 +0000
commitf5ba72ea04e71a127031a4436781943008abfa7a (patch)
tree0da4f624a81d6f9d241a0e88fb4bc96fd9b46f2c /src/backend/utils/adt/formatting.c
parent0cec2bb0cd2ea1a19d2ad58107b04226de401d44 (diff)
Consolidate several near-identical uses of mktime() into a single
routine DetermineLocalTimeZone(). In that routine, be more wary of broken mktime() implementations than the original code was: don't allow mktime to change the already-set y/m/d/h/m/s information, and don't use tm_gmtoff if mktime failed. Possibly this will resolve some of the complaints we've been hearing from users of Middle Eastern timezones on RedHat.
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r--src/backend/utils/adt/formatting.c34
1 files changed, 2 insertions, 32 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 7e68d7e984e..1ad99d330e5 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* formatting.c
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.36 2001/03/23 04:49:54 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.37 2001/05/03 22:53:07 tgl Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
@@ -2936,37 +2936,7 @@ to_timestamp(PG_FUNCTION_ARGS)
#ifdef DEBUG_TO_FROM_CHAR
NOTICE_TM;
#endif
- if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
- {
-
-#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
- tm->tm_isdst = -1;
- tm->tm_year -= 1900;
- tm->tm_mon -= 1;
-
-#ifdef DEBUG_TO_FROM_CHAR
- elog(DEBUG_elog_output, "TO-FROM_CHAR: Call mktime()");
- NOTICE_TM;
-#endif
- mktime(tm);
- tm->tm_year += 1900;
- tm->tm_mon += 1;
-
-#if defined(HAVE_TM_ZONE)
- tz = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
-#elif defined(HAVE_INT_TIMEZONE)
- tz = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
-#endif
-
-#else /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */
- tz = CTimeZone;
-#endif
- }
- else
- {
- tm->tm_isdst = 0;
- tz = 0;
- }
+ tz = DetermineLocalTimeZone(tm);
#ifdef DEBUG_TO_FROM_CHAR
NOTICE_TM;
#endif