summaryrefslogtreecommitdiffstats
path: root/runtime/datetime.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-11-18 11:40:23 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2008-11-18 11:40:23 +0100
commita5417f16044d7d56dbceeea09e25ba3e8c47cc01 (patch)
treede086d9f0baa496f3743b39e4c49b05edab1a303 /runtime/datetime.c
parentba201a941435bc5fec2c333155e1a8e16c4a9c05 (diff)
parent704a1145d64532df36624a3c9850b0c86f38f76f (diff)
downloadrsyslog-a5417f16044d7d56dbceeea09e25ba3e8c47cc01.tar.gz
rsyslog-a5417f16044d7d56dbceeea09e25ba3e8c47cc01.tar.xz
rsyslog-a5417f16044d7d56dbceeea09e25ba3e8c47cc01.zip
Merge branch 'nextmaster'
Diffstat (limited to 'runtime/datetime.c')
-rw-r--r--runtime/datetime.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime/datetime.c b/runtime/datetime.c
index 20ca6191..aa1956d7 100644
--- a/runtime/datetime.c
+++ b/runtime/datetime.c
@@ -62,9 +62,14 @@ DEFobjCurrIf(errmsg)
* most portable and removes the need for additional structures
* (but I have to admit it is somewhat "bulky";)).
*
- * Obviously, all caller-provided pointers must not be NULL...
+ * Obviously, *t must not be NULL...
+ *
+ * rgerhards, 2008-10-07: added ttSeconds to provide a way to
+ * obtain the second-resolution UNIX timestamp. This is needed
+ * in some situations to minimize time() calls (namely when doing
+ * output processing). This can be left NULL if not needed.
*/
-static void getCurrTime(struct syslogTime *t)
+static void getCurrTime(struct syslogTime *t, time_t *ttSeconds)
{
struct timeval tp;
struct tm *tm;
@@ -83,6 +88,9 @@ static void getCurrTime(struct syslogTime *t)
# else
gettimeofday(&tp, NULL);
# endif
+ if(ttSeconds != NULL)
+ *ttSeconds = tp.tv_sec;
+
tm = localtime_r((time_t*) &(tp.tv_sec), &tmBuf);
t->year = tm->tm_year + 1900;