diff options
Diffstat (limited to 'src/print_time.c')
-rw-r--r-- | src/print_time.c | 13 |
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(¤t_time); + (void)strftime(part, sizeof(part), format, current_tm); + printf("%s", part); +} |