blob: 2cf2ab3ad22e8bb73f69f0b6865cf6af0d1ea5c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
// 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);
if (current_time == (time_t) -1) {
return;
}
struct tm *current_tm = localtime(¤t_time);
if (current_tm == NULL) {
return;
}
(void)strftime(part, sizeof(part), format, current_tm);
printf("%s", part);
}
|