diff mbox series

[v3,2/2] timegm.3: Remove recommendation against their use

Message ID 20211011115406.11430-2-alx.manpages@gmail.com
State Not Applicable
Headers show
Series None | expand

Commit Message

Alejandro Colomar \(man-pages\) Oct. 11, 2021, 11:54 a.m. UTC
It was straight after a note that they are nonstandard functions,
which already tells the user that if portability is in mind, they
shouldn't be used, so this recommendation adds nothing in that

Also, there's a note that timelocal() should _never_ be used, due
to mktime() being identical and in the POSIX standard (it is also
in C99), so this note would also add nothing in that sense.

So the only uses not covered by those other notes are non-portable
uses of timegm(3).  In that scenario, it is an excellent function.

When porting to other systems, it is trivial to port timegm(3)
using only standard C (I didn't test it; use on your own):

// timegm.c
 #include <time.h>

time_t timegm(struct tm *tm)
	tm->tm_isdst = 0;
	return mktime(tm) - timezone;

Cc: Paul Eggert <eggert@cs.ucla.edu>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
 man3/timegm.3 | 1 -
 1 file changed, 1 deletion(-)
diff mbox series


diff --git a/man3/timegm.3 b/man3/timegm.3
index b848e83e1..0e8528b26 100644
--- a/man3/timegm.3
+++ b/man3/timegm.3
@@ -97,7 +97,6 @@  T}	Thread safety	MT-Safe env locale
 These functions are nonstandard GNU extensions
 that are also present on the BSDs.
-Avoid their use.
 .BR timelocal ()