aboutsummaryrefslogtreecommitdiff
path: root/src/polyfill.h
diff options
context:
space:
mode:
authorChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-05-13 12:43:58 -0400
committerChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-05-13 12:43:58 -0400
commit71026ea3ecb33b923f513f1e36cedbd89d6b7dc4 (patch)
tree164885af945a25fef0f63303263522848238285d /src/polyfill.h
parentbetter tests that also serve as temporary docs (diff)
add TM_GMTOFF and TM_ZONE
I might want to be able to write to them, but that seems very error-prone.
Diffstat (limited to 'src/polyfill.h')
-rw-r--r--src/polyfill.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/polyfill.h b/src/polyfill.h
index 5fa72ac..ecc3a0d 100644
--- a/src/polyfill.h
+++ b/src/polyfill.h
@@ -18,5 +18,23 @@ const char *janet_optcbytes(const Janet *argv, int32_t argc, int32_t n, const ch
static const int32_t CNAME##_sourceline_ = __LINE__; \
Janet CNAME (int32_t argc, Janet *argv)
#endif // !defined(JANET_NO_SOURCEMAPS)
-
#endif // JANET_VERSION_MAJOR < 2 && JANET_VERSION_MINOR < 28
+
+// ===
+
+// public domain code from
+// https://github.com/eggert/tz.git
+
+/* Infer TM_ZONE on systems where this information is known, but suppress
+ guessing if NO_TM_ZONE is defined. Similarly for TM_GMTOFF. */
+#if (defined __GLIBC__ \
+ || defined __tm_zone /* musl */ \
+ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \
+ || (defined __APPLE__ && defined __MACH__))
+# if !defined TM_GMTOFF && !defined NO_TM_GMTOFF
+# define TM_GMTOFF tm_gmtoff
+# endif
+# if !defined TM_ZONE && !defined NO_TM_ZONE
+# define TM_ZONE tm_zone
+# endif
+#endif