TIMEGM

Section: Manuel du programmeur Linux (3)
Updated: 2001-12-26
Index Retour au Menu Principal

 

NOM

timegm, timelocal - Fonctions réciproques de gmtime and localtime  

SYNOPSIS

#include <time.h>

time_t timelocal (struct tm *tm);

time_t timegm (struct tm *tm);
 

DESCRIPTION

Les fonctions timelocal() et timegm() sont les réciproques de localtime(3) et gmtime(3).  

NOTES

Ces fonctions sont des extensions GNU. La fonction timelocal() est équivalente à la fonction standard POSIX mktime(3). Il n'y a aucune raison de l'utiliser.

Afin d'obtenir une version portable de timegm(), positionnez la variable d'environnement TZ à UTC, appelez mktime() et restaurez la valeur de TZ. Soit un code similaire à

#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;
}
 

VOIR AUSSI

gmtime(3), localtime(3), mktime(3), tzset(3)  

TRADUCTION

Stéphan Rafin, 2002.



 

Index

NOM
SYNOPSIS
DESCRIPTION
NOTES
VOIR AUSSI
TRADUCTION


Time: 22:30:07 GMT, December 19, 2004