mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08: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
1899203f3d
commit
dadce6509a
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.119 2004/03/22 15:34:22 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.120 2004/05/05 17:28:46 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[128];
|
char buf[128];
|
||||||
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…
Reference in New Issue
Block a user