]> granicus.if.org Git - postgresql/commitdiff
Move timeofday() implementation out of nabstime.c.
authorAndres Freund <andres@anarazel.de>
Thu, 11 Oct 2018 18:30:59 +0000 (11:30 -0700)
committerAndres Freund <andres@anarazel.de>
Thu, 11 Oct 2018 18:30:59 +0000 (11:30 -0700)
nabstime.c is about to be removed, but timeofday() isn't related to
the rest of the functionality therein, and some find it useful. Move
to timestamp.c.

Discussion:
    https://postgr.es/m/20181009192237.34wjp3nmw7oynmmr@alap3.anarazel.de
    https://postgr.es/m/20180928223240.kgwc4czzzekrpsid%40alap3.anarazel.de

src/backend/utils/adt/nabstime.c
src/backend/utils/adt/timestamp.c

index 6ecb41b98f5b7f9aded1017839f69babe5918cd2..2c8e7ad055143c82f379c702ee9b0e26f9336856 100644 (file)
@@ -1539,32 +1539,3 @@ bogus:
                                        "tinterval", i_string)));
        *i_start = *i_end = INVALID_ABSTIME;    /* keep compiler quiet */
 }
-
-
-/*****************************************************************************
- *
- *****************************************************************************/
-
-/*
- * timeofday -
- *        returns the current time as a text. similar to timenow() but returns
- *        seconds with more precision (up to microsecs). (I need this to compare
- *        the Wisconsin benchmark with Illustra whose TimeNow() shows current
- *        time with precision up to microsecs.)                          - ay 3/95
- */
-Datum
-timeofday(PG_FUNCTION_ARGS)
-{
-       struct timeval tp;
-       char            templ[128];
-       char            buf[128];
-       pg_time_t       tt;
-
-       gettimeofday(&tp, NULL);
-       tt = (pg_time_t) tp.tv_sec;
-       pg_strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%06d %Y %Z",
-                               pg_localtime(&tt, session_timezone));
-       snprintf(buf, sizeof(buf), templ, tp.tv_usec);
-
-       PG_RETURN_TEXT_P(cstring_to_text(buf));
-}
index 284e14dd73983190a8b4171a0978fbd3355d2dd2..ba15a29ddbd93524a1bd6985bef58ef2c5db89f6 100644 (file)
@@ -1609,6 +1609,26 @@ GetSQLLocalTimestamp(int32 typmod)
        return ts;
 }
 
+/*
+ * timeofday(*) -- returns the current time as a text.
+ */
+Datum
+timeofday(PG_FUNCTION_ARGS)
+{
+       struct timeval tp;
+       char            templ[128];
+       char            buf[128];
+       pg_time_t       tt;
+
+       gettimeofday(&tp, NULL);
+       tt = (pg_time_t) tp.tv_sec;
+       pg_strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%06d %Y %Z",
+                               pg_localtime(&tt, session_timezone));
+       snprintf(buf, sizeof(buf), templ, tp.tv_usec);
+
+       PG_RETURN_TEXT_P(cstring_to_text(buf));
+}
+
 /*
  * TimestampDifference -- convert the difference between two timestamps
  *             into integer seconds and microseconds