summaryrefslogtreecommitdiff
path: root/src/modules/time.c
blob: 84f894edee504f9114818bd83a72fc67f2bd0f02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "time.h"

#include <stdlib.h>
#include <time.h>
#include <tgmath.h>

struct time *
time_new()
{
    struct time * t = malloc(sizeof(struct time));
    return t;
}

void
time_free(struct time * t)
{
    free(t);
}

void
time_update(struct time * t)
{
    time_t timer;
    struct tm * tm;

    time(&timer);
    tm = gmtime(&timer);
    strftime(t->value, TIME_VALUE_SIZE, "%F [%a] %T", tm);
}