diff options
| author | Sam Light <sam@lightscale.co.uk> | 2025-09-10 19:37:28 +0100 |
|---|---|---|
| committer | Sam Light <sam@lightscale.co.uk> | 2025-09-10 19:37:28 +0100 |
| commit | d9b456d738e5013d48f41f5e6315ef7c22d6acf0 (patch) | |
| tree | 2e3722f5697cbf883c4b16edc87726b9e510bce1 /src/modules/time.c | |
Initial commit
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); +} |
