mirror of
https://github.com/postgres/postgres.git
synced 2025-05-18 17:41:14 +03:00
Don't assume that struct timeval's tv_sec field is the same datatype as
time_t; on some platforms they are not the same width. Per Manfred Koizar.
This commit is contained in:
parent
31cf0d6bac
commit
69f5e41be3
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.117 2003/09/29 00:05:25 petere Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.117.2.1 2004/05/05 17:28:57 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -191,9 +191,9 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
|
|||||||
time -= CTimeZone;
|
time -= CTimeZone;
|
||||||
|
|
||||||
if ((!HasCTZSet) && (tzp != NULL))
|
if ((!HasCTZSet) && (tzp != NULL))
|
||||||
tx = localtime((time_t *) &time);
|
tx = localtime(&time);
|
||||||
else
|
else
|
||||||
tx = gmtime((time_t *) &time);
|
tx = gmtime(&time);
|
||||||
|
|
||||||
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;
|
||||||
@ -1728,10 +1728,12 @@ timeofday(PG_FUNCTION_ARGS)
|
|||||||
char buf[100];
|
char buf[100];
|
||||||
text *result;
|
text *result;
|
||||||
int len;
|
int len;
|
||||||
|
time_t tt;
|
||||||
|
|
||||||
gettimeofday(&tp, &tpz);
|
gettimeofday(&tp, &tpz);
|
||||||
|
tt = (time_t) tp.tv_sec;
|
||||||
strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%06d %Y %Z",
|
strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%06d %Y %Z",
|
||||||
localtime((time_t *) &tp.tv_sec));
|
localtime(&tt));
|
||||||
snprintf(buf, sizeof(buf), templ, tp.tv_usec);
|
snprintf(buf, sizeof(buf), templ, tp.tv_usec);
|
||||||
|
|
||||||
len = VARHDRSZ + strlen(buf);
|
len = VARHDRSZ + strlen(buf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user