Correct bogus output formatting of timeofday() function. A number of

microseconds < 100000 should be displayed as, eg, 13.000126, not 13.126.
This commit is contained in:
Tom Lane 2001-02-21 22:03:00 +00:00
parent 15903a1ed4
commit 4dba6814a3

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.81 2001/02/13 14:32:52 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.82 2001/02/21 22:03:00 tgl Exp $
* *
* NOTES * NOTES
* *
@ -1911,13 +1911,13 @@ timeofday(PG_FUNCTION_ARGS)
{ {
struct timeval tp; struct timeval tp;
struct timezone tpz; struct timezone tpz;
char templ[500]; char templ[100];
char buf[500]; char buf[100];
text *result; text *result;
int len = 0; int len;
gettimeofday(&tp, &tpz); gettimeofday(&tp, &tpz);
strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%d %Y %Z", strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%06d %Y %Z",
localtime((time_t *) &tp.tv_sec)); localtime((time_t *) &tp.tv_sec));
snprintf(buf, sizeof(buf), templ, tp.tv_usec); snprintf(buf, sizeof(buf), templ, tp.tv_usec);