aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-06-03 02:08:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-06-03 02:08:07 +0000
commit921d749bd4c34c3349f1c254d5faa2f1cec03911 (patch)
treec349959cb92495a8231020062fa46ac1c2b57afd /src/backend/utils
parent473ac70acae41c5f1fecbb0b57e9f5be5b26ab68 (diff)
downloadpostgresql-921d749bd4c34c3349f1c254d5faa2f1cec03911.tar.gz
postgresql-921d749bd4c34c3349f1c254d5faa2f1cec03911.zip
Adjust our timezone library to use pg_time_t (typedef'd as int64) in
place of time_t, as per prior discussion. The behavior does not change on machines without a 64-bit-int type, but on machines with one, which is most, we are rid of the bizarre boundary behavior at the edges of the 32-bit-time_t range (1901 and 2038). The system will now treat times over the full supported timestamp range as being in your local time zone. It may seem a little bizarre to consider that times in 4000 BC are PST or EST, but this is surely at least as reasonable as propagating Gregorian calendar rules back that far. I did not modify the format of the zic timezone database files, which means that for the moment the system will not know about daylight-savings periods outside the range 1901-2038. Given the way the files are set up, it's not a simple decision like 'widen to 64 bits'; we have to actually think about the range of years that need to be supported. We should probably inquire what the plans of the upstream zic people are before making any decisions of our own.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/date.c32
-rw-r--r--src/backend/utils/adt/datetime.c199
-rw-r--r--src/backend/utils/adt/nabstime.c11
-rw-r--r--src/backend/utils/adt/timestamp.c139
-rw-r--r--src/backend/utils/error/elog.c14
5 files changed, 199 insertions, 196 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 91ef127a94a..1caa68d774b 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.98 2004/05/31 18:53:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.99 2004/06/03 02:08:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,7 +23,6 @@
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "parser/scansup.h"
-#include "pgtime.h"
#include "utils/builtins.h"
#include "utils/date.h"
#include "utils/nabstime.h"
@@ -295,35 +294,22 @@ date2timestamptz(DateADT dateVal)
TimestampTz result;
struct pg_tm tt,
*tm = &tt;
+ int tz;
j2date(dateVal + POSTGRES_EPOCH_JDATE,
&(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday));
- if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
- {
- int tz;
-
- tm->tm_hour = 0;
- tm->tm_min = 0;
- tm->tm_sec = 0;
- tz = DetermineLocalTimeZone(tm);
+ tm->tm_hour = 0;
+ tm->tm_min = 0;
+ tm->tm_sec = 0;
+ tz = DetermineLocalTimeZone(tm);
#ifdef HAVE_INT64_TIMESTAMP
- result = (dateVal * INT64CONST(86400000000))
- + (tz * INT64CONST(1000000));
-#else
- result = dateVal * 86400.0 + tz;
-#endif
- }
- else
- {
- /* Outside of range for timezone support, so assume UTC */
-#ifdef HAVE_INT64_TIMESTAMP
- result = (dateVal * INT64CONST(86400000000));
+ result = (dateVal * INT64CONST(86400000000))
+ + (tz * INT64CONST(1000000));
#else
- result = dateVal * 86400.0;
+ result = dateVal * 86400.0 + tz;
#endif
- }
return result;
}
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 4284e4c5e32..6fdefc536e8 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.129 2004/05/31 18:53:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.130 2004/06/03 02:08:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,9 +40,11 @@ static int DecodeDate(char *str, int fmask, int *tmask, struct pg_tm * tm);
static void TrimTrailingZeros(char *str);
-int day_tab[2][13] = {
+const int day_tab[2][13] =
+{
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
-{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
+ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}
+};
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
@@ -1572,115 +1574,126 @@ DecodeDateTime(char **field, int *ftype, int nf,
* (ie, regular or daylight-savings time) at that time. Set the struct pg_tm's
* tm_isdst field accordingly, and return the actual timezone offset.
*
- * Note: this subroutine exists because mktime() has such a spectacular
- * variety of, ahem, odd behaviors on various platforms. We used to try to
- * use mktime() here, but finally gave it up as a bad job. Avoid using
- * mktime() anywhere else.
+ * Note: it might seem that we should use mktime() for this, but bitter
+ * experience teaches otherwise. In particular, mktime() is generally
+ * incapable of coping reasonably with "impossible" times within a
+ * spring-forward DST transition. Typical implementations of mktime()
+ * turn out to be loops around localtime() anyway, so they're not even
+ * any faster than this code.
*/
int
-DetermineLocalTimeZone(struct pg_tm * tm)
+DetermineLocalTimeZone(struct pg_tm *tm)
{
int tz;
+ int date,
+ sec;
+ pg_time_t day,
+ mysec,
+ locsec,
+ delta1,
+ delta2;
+ struct pg_tm *tx;
if (HasCTZSet)
{
tm->tm_isdst = 0; /* for lack of a better idea */
- tz = CTimeZone;
+ return CTimeZone;
}
- else if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
- {
- /*
- * First, generate the time_t value corresponding to the given
- * y/m/d/h/m/s taken as GMT time. This will not overflow (at
- * least not for time_t taken as signed) because of the range
- * check we did above.
- */
- long day,
- mysec,
- locsec,
- delta1,
- delta2;
- time_t mytime;
- struct pg_tm *tx;
-
- day = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - UNIX_EPOCH_JDATE;
- mysec = tm->tm_sec + (tm->tm_min + (day * 24 + tm->tm_hour) * 60) * 60;
- mytime = (time_t) mysec;
- /*
- * Use localtime to convert that time_t to broken-down time,
- * and reassemble to get a representation of local time.
- */
- tx = pg_localtime(&mytime);
- if (!tx)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
- UNIX_EPOCH_JDATE;
- locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
+ /*
+ * First, generate the pg_time_t value corresponding to the given
+ * y/m/d/h/m/s taken as GMT time. If this overflows, punt and
+ * decide the timezone is GMT. (We only need to worry about overflow
+ * on machines where pg_time_t is 32 bits.)
+ */
+ if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday))
+ goto overflow;
+ date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - UNIX_EPOCH_JDATE;
+ day = ((pg_time_t) date) * 86400;
+ if (day / 86400 != date)
+ goto overflow;
+ sec = tm->tm_sec + (tm->tm_min + tm->tm_hour * 60) * 60;
+ mysec = day + sec;
+ /* since sec >= 0, overflow could only be from +day to -mysec */
+ if (mysec < 0 && day > 0)
+ goto overflow;
- /*
- * The local time offset corresponding to that GMT time is now
- * computable as mysec - locsec.
- */
- delta1 = mysec - locsec;
- /*
- * However, if that GMT time and the local time we are
- * actually interested in are on opposite sides of a
- * daylight-savings-time transition, then this is not the time
- * offset we want. So, adjust the time_t to be what we think
- * the GMT time corresponding to our target local time is, and
- * repeat the localtime() call and delta calculation.
- */
- mysec += delta1;
- mytime = (time_t) mysec;
- tx = pg_localtime(&mytime);
+ /*
+ * Use pg_localtime to convert that pg_time_t to broken-down time,
+ * and reassemble to get a representation of local time. (We could get
+ * overflow of a few hours in the result, but the delta calculation
+ * should still work.)
+ */
+ tx = pg_localtime(&mysec);
+ if (!tx)
+ goto overflow; /* probably can't happen */
+ day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
+ UNIX_EPOCH_JDATE;
+ locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
+
+ /*
+ * The local time offset corresponding to that GMT time is now
+ * computable as mysec - locsec.
+ */
+ delta1 = mysec - locsec;
+
+ /*
+ * However, if that GMT time and the local time we are
+ * actually interested in are on opposite sides of a
+ * daylight-savings-time transition, then this is not the time
+ * offset we want. So, adjust the pg_time_t to be what we think
+ * the GMT time corresponding to our target local time is, and
+ * repeat the pg_localtime() call and delta calculation.
+ *
+ * We have to watch out for overflow while adjusting the pg_time_t.
+ */
+ if ((delta1 < 0) ? (mysec < 0 && (mysec + delta1) > 0) :
+ (mysec > 0 && (mysec + delta1) < 0))
+ goto overflow;
+ mysec += delta1;
+ tx = pg_localtime(&mysec);
+ if (!tx)
+ goto overflow; /* probably can't happen */
+ day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
+ UNIX_EPOCH_JDATE;
+ locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
+ delta2 = mysec - locsec;
+
+ /*
+ * We may have to do it again to get the correct delta.
+ *
+ * It might seem we should just loop until we get the same delta
+ * twice in a row, but if we've been given an "impossible" local
+ * time (in the gap during a spring-forward transition) we'd never
+ * get out of the loop. The behavior we want is that "impossible"
+ * times are taken as standard time, and also that ambiguous times
+ * (during a fall-back transition) are taken as standard time.
+ * Therefore, we bias the code to prefer the standard-time solution.
+ */
+ if (delta2 != delta1 && tx->tm_isdst != 0)
+ {
+ delta2 -= delta1;
+ if ((delta2 < 0) ? (mysec < 0 && (mysec + delta2) > 0) :
+ (mysec > 0 && (mysec + delta2) < 0))
+ goto overflow;
+ mysec += delta2;
+ tx = pg_localtime(&mysec);
if (!tx)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
+ goto overflow; /* probably can't happen */
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
UNIX_EPOCH_JDATE;
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
delta2 = mysec - locsec;
-
- /*
- * We may have to do it again to get the correct delta.
- *
- * It might seem we should just loop until we get the same delta
- * twice in a row, but if we've been given an "impossible" local
- * time (in the gap during a spring-forward transition) we'd never
- * get out of the loop. The behavior we want is that "impossible"
- * times are taken as standard time, and also that ambiguous times
- * (during a fall-back transition) are taken as standard time.
- * Therefore, we bias the code to prefer the standard-time solution.
- */
- if (delta2 != delta1 && tx->tm_isdst != 0)
- {
- mysec += (delta2 - delta1);
- mytime = (time_t) mysec;
- tx = pg_localtime(&mytime);
- if (!tx)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
- UNIX_EPOCH_JDATE;
- locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
- delta2 = mysec - locsec;
- }
- tm->tm_isdst = tx->tm_isdst;
- tz = (int) delta2;
- }
- else
- {
- /* Given date is out of range, so assume UTC */
- tm->tm_isdst = 0;
- tz = 0;
}
+ tm->tm_isdst = tx->tm_isdst;
+ tz = (int) delta2;
return tz;
+
+overflow:
+ /* Given date is out of range, so assume UTC */
+ tm->tm_isdst = 0;
+ return 0;
}
diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c
index 0443072e8e0..8353fa26583 100644
--- a/src/backend/utils/adt/nabstime.c
+++ b/src/backend/utils/adt/nabstime.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.122 2004/05/21 16:08:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.123 2004/06/03 02:08:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,6 +19,7 @@
#include <ctype.h>
#include <float.h>
#include <limits.h>
+#include <time.h>
#include <sys/time.h>
#include "access/xact.h"
@@ -179,7 +180,7 @@ GetCurrentTimeUsec(struct pg_tm * tm, fsec_t *fsec, int *tzp)
void
abstime2tm(AbsoluteTime _time, int *tzp, struct pg_tm * tm, char **tzn)
{
- time_t time = (time_t) _time;
+ pg_time_t time = (pg_time_t) _time;
struct pg_tm *tx;
/*
@@ -1667,12 +1668,12 @@ timeofday(PG_FUNCTION_ARGS)
char buf[128];
text *result;
int len;
- time_t tt;
+ pg_time_t tt;
gettimeofday(&tp, &tpz);
- tt = (time_t) tp.tv_sec;
+ tt = (pg_time_t) tp.tv_sec;
pg_strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%06d %Y %Z",
- pg_localtime(&tt));
+ pg_localtime(&tt));
snprintf(buf, sizeof(buf), templ, tp.tv_usec);
len = VARHDRSZ + strlen(buf);
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index d40715b7e44..91a34ed5388 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.107 2004/05/31 18:31:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.108 2004/06/03 02:08:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -921,16 +921,14 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
} /* dt2time() */
-/* timestamp2tm()
- * Convert timestamp data type to POSIX time structure.
+/*
+ * timestamp2tm() - Convert timestamp data type to POSIX time structure.
+ *
* Note that year is _not_ 1900-based, but is an explicit full value.
* Also, month is one-based, _not_ zero-based.
* Returns:
* 0 on success
* -1 on out of range
- *
- * For dates within the system-supported time_t range, convert to the
- * local time zone. If out of this range, leave as GMT. - tgl 97/05/27
*/
int
timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, char **tzn)
@@ -942,8 +940,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, char **tzn)
double date;
double time;
#endif
- time_t utime;
- struct pg_tm *tx;
+ pg_time_t utime;
/*
* If HasCTZSet is true then we have a brute force time zone
@@ -988,70 +985,77 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, char **tzn)
j2date((int) date, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
dt2time(time, &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
- if (tzp != NULL)
+ /* Done if no TZ conversion wanted */
+ if (tzp == NULL)
{
- /*
- * We have a brute force time zone per SQL99? Then use it without
- * change since we have already rotated to the time zone.
- */
- if (HasCTZSet)
- {
- *tzp = CTimeZone;
- tm->tm_isdst = 0;
- tm->tm_gmtoff = CTimeZone;
- tm->tm_zone = NULL;
- if (tzn != NULL)
- *tzn = NULL;
- }
+ tm->tm_isdst = -1;
+ tm->tm_gmtoff = 0;
+ tm->tm_zone = NULL;
+ if (tzn != NULL)
+ *tzn = NULL;
+ return 0;
+ }
- /*
- * Does this fall within the capabilities of the localtime()
- * interface? Then use this to rotate to the local time zone.
- */
- else if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
- {
- /*
- * Convert to integer, avoiding platform-specific
- * roundoff-in-wrong-direction errors, and adjust to
- * Unix epoch. Note we have to do this in one step
- * because the intermediate result before adjustment
- * won't necessarily fit in an int32.
- */
+ /*
+ * We have a brute force time zone per SQL99? Then use it without
+ * change since we have already rotated to the time zone.
+ */
+ if (HasCTZSet)
+ {
+ *tzp = CTimeZone;
+ tm->tm_isdst = 0;
+ tm->tm_gmtoff = CTimeZone;
+ tm->tm_zone = NULL;
+ if (tzn != NULL)
+ *tzn = NULL;
+ return 0;
+ }
+
+ /*
+ * If the time falls within the range of pg_time_t, use pg_localtime()
+ * to rotate to the local time zone.
+ *
+ * First, convert to an integral timestamp, avoiding possibly
+ * platform-specific roundoff-in-wrong-direction errors, and adjust to
+ * Unix epoch. Then see if we can convert to pg_time_t without loss.
+ * This coding avoids hardwiring any assumptions about the width of
+ * pg_time_t, so it should behave sanely on machines without int64.
+ */
#ifdef HAVE_INT64_TIMESTAMP
- utime = (dt - *fsec) / INT64CONST(1000000) +
- (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * 86400;
+ dt = (dt - *fsec) / INT64CONST(1000000) +
+ (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * 86400;
#else
- utime = rint(dt - *fsec +
- (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * 86400);
+ dt = rint(dt - *fsec +
+ (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * 86400);
#endif
-
- tx = pg_localtime(&utime);
- tm->tm_year = tx->tm_year + 1900;
- tm->tm_mon = tx->tm_mon + 1;
- tm->tm_mday = tx->tm_mday;
- tm->tm_hour = tx->tm_hour;
- tm->tm_min = tx->tm_min;
- tm->tm_sec = tx->tm_sec;
- tm->tm_isdst = tx->tm_isdst;
- tm->tm_gmtoff = tx->tm_gmtoff;
- tm->tm_zone = tx->tm_zone;
-
- *tzp = -(tm->tm_gmtoff);
- if (tzn != NULL)
- *tzn = (char *) tm->tm_zone;
- }
- else
- {
- *tzp = 0;
- /* Mark this as *no* time zone available */
- tm->tm_isdst = -1;
- if (tzn != NULL)
- *tzn = NULL;
- }
+ utime = (pg_time_t) dt;
+ if ((Timestamp) utime == dt)
+ {
+ struct pg_tm *tx = pg_localtime(&utime);
+
+ tm->tm_year = tx->tm_year + 1900;
+ tm->tm_mon = tx->tm_mon + 1;
+ tm->tm_mday = tx->tm_mday;
+ tm->tm_hour = tx->tm_hour;
+ tm->tm_min = tx->tm_min;
+ tm->tm_sec = tx->tm_sec;
+ tm->tm_isdst = tx->tm_isdst;
+ tm->tm_gmtoff = tx->tm_gmtoff;
+ tm->tm_zone = tx->tm_zone;
+ *tzp = -(tm->tm_gmtoff);
+ if (tzn != NULL)
+ *tzn = (char *) tm->tm_zone;
}
else
{
+ /*
+ * When out of range of pg_time_t, treat as GMT
+ */
+ *tzp = 0;
+ /* Mark this as *no* time zone available */
tm->tm_isdst = -1;
+ tm->tm_gmtoff = 0;
+ tm->tm_zone = NULL;
if (tzn != NULL)
*tzn = NULL;
}
@@ -1224,7 +1228,7 @@ void
GetEpochTime(struct pg_tm * tm)
{
struct pg_tm *t0;
- time_t epoch = 0;
+ pg_time_t epoch = 0;
t0 = pg_gmtime(&epoch);
@@ -1235,12 +1239,9 @@ GetEpochTime(struct pg_tm * tm)
tm->tm_min = t0->tm_min;
tm->tm_sec = t0->tm_sec;
- if (tm->tm_year < 1900)
- tm->tm_year += 1900;
+ tm->tm_year += 1900;
tm->tm_mon++;
-
- return;
-} /* GetEpochTime() */
+}
Timestamp
SetEpochTimestamp(void)
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index e3adab82979..dc881a0067b 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.139 2004/05/29 22:48:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.140 2004/06/03 02:08:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,6 +45,7 @@
#include <fcntl.h>
#include <errno.h>
+#include <time.h>
#include <unistd.h>
#include <signal.h>
#include <ctype.h>
@@ -56,7 +57,6 @@
#include "libpq/pqformat.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
-#include "pgtime.h"
#include "postmaster/postmaster.h"
#include "storage/ipc.h"
#include "tcop/tcopprot.h"
@@ -1217,8 +1217,9 @@ log_line_prefix(StringInfo buf)
time_t stamp_time = time(NULL);
char strfbuf[128];
- pg_strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S %Z",
- pg_localtime(&stamp_time));
+ strftime(strfbuf, sizeof(strfbuf),
+ "%Y-%m-%d %H:%M:%S %Z",
+ localtime(&stamp_time));
appendStringInfoString(buf, strfbuf);
}
break;
@@ -1228,8 +1229,9 @@ log_line_prefix(StringInfo buf)
time_t stamp_time = MyProcPort->session_start.tv_sec;
char strfbuf[128];
- pg_strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S %Z",
- pg_localtime(&stamp_time));
+ strftime(strfbuf, sizeof(strfbuf),
+ "%Y-%m-%d %H:%M:%S %Z",
+ localtime(&stamp_time));
appendStringInfoString(buf, strfbuf);
}
break;