aboutsummaryrefslogtreecommitdiff
path: root/lib/time/time_defs.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-01 17:39:20 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-01 17:39:20 -0400
commit2538b1b7461f9b06d6a6f43acd5609d916b1addc (patch)
tree061efdfc54351b1c644f1422e4f2c00bfefb1235 /lib/time/time_defs.h
parentd6d3f5711de85ab1c21f515b9d125d316d853c92 (diff)
parentadc2d81b5683e611c5f3289be6157d4519a60632 (diff)
Merge branch 'main' into formatter
Diffstat (limited to 'lib/time/time_defs.h')
-rw-r--r--lib/time/time_defs.h34
1 files changed, 0 insertions, 34 deletions
diff --git a/lib/time/time_defs.h b/lib/time/time_defs.h
deleted file mode 100644
index eac3f23a..00000000
--- a/lib/time/time_defs.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Some helper logic for working with times.
-
-#pragma once
-#include <stdlib.h>
-#include <sys/time.h>
-#include <time.h>
-
-typedef struct timeval Time;
-
-static OptionalText_t _local_timezone = NONE_TEXT;
-
-static INLINE Text_t num_format(long n, const char *unit) {
- if (n == 0) return Text("now");
- return Text$from_str(
- String((int64_t)labs(n), " ", unit, (n == -1 || n == 1) ? "" : "s", n <= 0 ? " ago" : " later"));
-}
-
-static void set_local_timezone(Text_t tz) {
- setenv("TZ", Text$as_c_string(tz), 1);
- _local_timezone = tz;
- tzset();
-}
-
-#define WITH_TIMEZONE(tz, body) \
- ({ \
- if (tz.length >= 0) { \
- OptionalText_t old_timezone = _local_timezone; \
- set_local_timezone(tz); \
- body; \
- set_local_timezone(old_timezone); \
- } else { \
- body; \
- } \
- })