Back to index

glibc  2.9
timegm.c
Go to the documentation of this file.
00001 /* Convert UTC calendar time to simple time.  Like mktime but assumes UTC.
00002 
00003    Copyright (C) 1994, 1997, 2003 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifdef HAVE_CONFIG_H
00022 # include <config.h>
00023 #endif
00024 
00025 #ifdef _LIBC
00026 # include <time.h>
00027 #else
00028 # include "timegm.h"
00029 
00030 /* Portable standalone applications should supply a "time_r.h" that
00031    declares a POSIX-compliant gmtime_r, for the benefit of older
00032    implementations that lack gmtime_r or have a nonstandard one.
00033    See the gnulib time_r module for one way to implement this.  */
00034 # include <time_r.h>
00035 # undef __gmtime_r
00036 # define __gmtime_r gmtime_r
00037 time_t __mktime_internal (struct tm *,
00038                        struct tm * (*) (time_t const *, struct tm *),
00039                        time_t *);
00040 #endif
00041 
00042 time_t
00043 timegm (struct tm *tmp)
00044 {
00045   static time_t gmtime_offset;
00046   tmp->tm_isdst = 0;
00047   return __mktime_internal (tmp, __gmtime_r, &gmtime_offset);
00048 }