]> granicus.if.org Git - postgresql/commitdiff
Correct bogus output formatting of timeofday() function. A number of
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 21 Feb 2001 22:03:00 +0000 (22:03 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 21 Feb 2001 22:03:00 +0000 (22:03 +0000)
microseconds < 100000 should be displayed as, eg, 13.000126, not 13.126.

src/backend/utils/adt/nabstime.c

index 31117389b0a991e25a92f08ec91167b3ec13ad06..99dc95d4663268faa9692c6d650e3b2f3577c7e8 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * 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
  *
@@ -1911,13 +1911,13 @@ timeofday(PG_FUNCTION_ARGS)
 {
        struct timeval tp;
        struct timezone tpz;
-       char            templ[500];
-       char            buf[500];
+       char            templ[100];
+       char            buf[100];
        text       *result;
-       int                     len = 0;
+       int                     len;
 
        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));
        snprintf(buf, sizeof(buf), templ, tp.tv_usec);