summaryrefslogtreecommitdiff
path: root/src/print_time.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/print_time.c')
-rw-r--r--src/print_time.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/print_time.c b/src/print_time.c
new file mode 100644
index 0000000..6871437
--- /dev/null
+++ b/src/print_time.c
@@ -0,0 +1,13 @@
+// vim:ts=8:expandtab
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void print_time(const char *format) {
+ static char part[512];
+ /* Get date & time */
+ time_t current_time = time(NULL);
+ struct tm *current_tm = localtime(&current_time);
+ (void)strftime(part, sizeof(part), format, current_tm);
+ printf("%s", part);
+}