tstatus/datetime.c

20 lines
407 B
C
Raw Normal View History

2022-09-25 10:35:26 -05:00
/* see LICENSE file for details on license */
#include <stdio.h>
#include <time.h>
#include "datetime.h"
int datetime_update(struct module *module) {
time_t t = time(NULL);
if(t == -1) return -1;
struct tm *tm = localtime(&t);
if(!tm) return -1;
snprintf((char *)&module->buffer,
MODULE_BUFFER_LEN, "%.02i%.02i-%.02i:%.02i",
tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min);
return 0;
}