aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kerrisk <mtk.manpages@gmail.com>2016-03-10 19:26:55 +0100
committerMichael Kerrisk <mtk.manpages@gmail.com>2016-03-11 00:42:36 +0100
commit25a0440e45c9f8b692e8aba522b611c99d1647a7 (patch)
tree833d02679cd8716eb5bfc296f1e1eacd472852ef
parent813596e5f23acb73ca74f0b35ba897854c3c9fb6 (diff)
downloadman-pages-25a0440e45c9f8b692e8aba522b611c99d1647a7.tar.gz
timegm.3: Remove sample implementation of timegm()
Stephen and Mats both question the wisdom of showing a portable *non-thread-safe* implementation of timegm(), and I find it hard to disagree. So, remove this code. See https://bugzilla.kernel.org/show_bug.cgi?id=103701 Reported-by: Stephen Hurd <shurd@sasktel.net> Reported-by: Mats Wichmann <mats@linuxfoundation.org> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
-rw-r--r--man3/timegm.340
1 files changed, 1 insertions, 39 deletions
diff --git a/man3/timegm.3 b/man3/timegm.3
index 4e742458b0..ed80cdbe41 100644
--- a/man3/timegm.3
+++ b/man3/timegm.3
@@ -70,51 +70,13 @@ T} Thread safety MT-Safe env locale
.SH CONFORMING TO
These functions are nonstandard GNU extensions
that are also present on the BSDs.
-Avoid their use; see NOTES.
+Avoid their use.
.SH NOTES
The
.BR timelocal ()
function is equivalent to the POSIX standard function
.BR mktime (3).
There is no reason to ever use it.
-.LP
-For a portable version of
-.BR timegm (),
-set the
-.B TZ
-environment variable to UTC, call
-.BR mktime (3)
-and restore the value of
-.BR TZ .
-Something like
-
-.in +4n
-.nf
-#include <time.h>
-#include <stdlib.h>
-
-time_t
-my_timegm(struct tm *tm)
-{
- time_t ret;
- char *tz;
-
- tz = getenv("TZ");
- if (tz)
- tz = strdup(tz);
- setenv("TZ", "", 1);
- tzset();
- ret = mktime(tm);
- if (tz) {
- setenv("TZ", tz, 1);
- free(tz);
- } else
- unsetenv("TZ");
- tzset();
- return ret;
-}
-.fi
-.in
.SH SEE ALSO
.BR gmtime (3),
.BR localtime (3),