diff options
Diffstat (limited to 'src/modules/time.c')
| -rw-r--r-- | src/modules/time.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/modules/time.c b/src/modules/time.c new file mode 100644 index 0000000..84f894e --- /dev/null +++ b/src/modules/time.c @@ -0,0 +1,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); +} |
