aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.h1
-rw-r--r--lib/xwrap.c11
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/lib.h b/lib/lib.h
index 621ed276..a659b696 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -128,6 +128,7 @@ char *xreadlink(char *name);
long xparsetime(char *arg, long units, long *fraction);
void xpidfile(char *name);
void xregcomp(regex_t *preg, char *rexec, int cflags);
+char *xtzset(char *new);
// lib.c
void verror_msg(char *msg, int err, va_list va);
diff --git a/lib/xwrap.c b/lib/xwrap.c
index cd3c6845..0a2b38ff 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -627,3 +627,14 @@ void xregcomp(regex_t *preg, char *regex, int cflags)
error_exit("xregcomp: %s", libbuf);
}
}
+
+char *xtzset(char *new)
+{
+ char *tz = getenv("TZ");
+
+ if (tz) tz = xstrdup(tz);
+ if (setenv("TZ", new, 1)) perror_exit("setenv");
+ tzset();
+
+ return tz;
+}