aboutsummaryrefslogtreecommitdiff
path: root/lib/time/time_defs.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-01 17:37:24 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-01 17:37:24 -0400
commit12345a85d9c7d7a56ddf323247a4bdf347021b73 (patch)
tree93bafb42c1ec2c22cc2858936034901c39cbca82 /lib/time/time_defs.h
parentc778c8822f1c8acf981e26f7b860a384c94cff6f (diff)
parentadc2d81b5683e611c5f3289be6157d4519a60632 (diff)
Merge branch 'main' into optional-list-indexing
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; \
- } \
- })