This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
quick-text-bar/modules/time.c

22 lines
519 B
C
Raw Permalink Normal View History

2022-08-28 14:27:03 -07:00
#include "time.h"
#include "../util.h"
#include <time.h>
#include <string.h>
#include <stdlib.h>
#define TIME_STRING_SIZE 64
#define TIME_FORMAT " %a %b %d  %R"
char *time_module_poll() {
time_t time_num = time(NULL);
struct tm time_tm;
localtime_r(&time_num, &time_tm);
char *output = qtb_malloc(TIME_STRING_SIZE);
int result = strftime(output, TIME_STRING_SIZE, TIME_FORMAT, &time_tm);
if (result == 0) {
strcpy(output, " ?? ?? ??  ??:??");
}
return output;
}