Scroll to navigation

TIMEGM(3) Manual del Programador de Linux TIMEGM(3)

NOMBRE

timegm, timelocal - funciones inversas para gmtime y localtime

SINOPSIS

#include <time.h>
time_t timelocal (struct tm *tm);
time_t timegm (struct tm *tm);

DESCRIPCIÓN

Las funciones timelocal() y timegm() son las inversas de localtime(3) y gmtime(3).

OBSERVACIONES

Estas funciones son extensiones de GNU. La función timelocal() es equivalente a la función del estándar POSIX mktime(3). No hay razón para usarla.
Para obtener una versión portable de timegm(), asigne a la variable de entorno TZ el valor UTC, llame a mktime() y restablezca el valor de TZ. Algo así como
#include <time.h>
#include <stdlib.h>
time_t my_timegm (struct tm *tm) { time_t ret; char *tz;
tz = getenv("TZ"); setenv("TZ", "", 1); tzset(); ret = mktime(tm); if (tz) setenv("TZ", tz, 1); else unsetenv("TZ"); tzset(); return ret; }

VÉASE TAMBIÉN

gmtime(3), localtime(3), mktime(3), tzset(3)
26 diciembre 2001 GNU