|
@@ -0,0 +1,23 @@
|
|
|
|
|
+#include <time.h>
|
|
|
|
|
+#include <sys/time.h>
|
|
|
|
|
+#include <stdlib.h>
|
|
|
|
|
+#include <stdio.h>
|
|
|
|
|
+#include <unistd.h>
|
|
|
|
|
+
|
|
|
|
|
+void printdate(FILE *fd)
|
|
|
|
|
+{
|
|
|
|
|
+ struct timespec tp;
|
|
|
|
|
+ char buf[64U] = "!DATE!";
|
|
|
|
|
+ size_t tail;
|
|
|
|
|
+
|
|
|
|
|
+ if (!clock_gettime(CLOCK_REALTIME, &tp)) {
|
|
|
|
|
+ tail = strftime(buf, sizeof buf, "%x %X", localtime(&tp.tv_sec));
|
|
|
|
|
+
|
|
|
|
|
+ if ((tail > 0) && (sizeof buf < tail)) {
|
|
|
|
|
+ snprintf(buf + tail, (sizeof buf) - tail, ".%03ld", (tp.tv_nsec / 1000000));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fprintf(fd, "%s: ", buf);
|
|
|
|
|
+}
|
|
|
|
|
+
|