X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmktime.c;h=c8ecd07f12b6592b92b6425e7bf353d316b41550;hb=b2dc4ba801547267ee35c2a5117c2b4ca8a9acbf;hp=1feb4046b07f631108526dc655a9723fde1a6710;hpb=7f20e762e847b2f6be6e83600b63674c69829c7a;p=gnulib.git diff --git a/lib/mktime.c b/lib/mktime.c index 1feb4046b..c8ecd07f1 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -1,24 +1,22 @@ -/* mktime: convert a `struct tm' to a time_t value - Copyright (C) 1993-1998, 1999 Free Software Foundation, Inc. +/* Convert a `struct tm' to a time_t value. + Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. + This file is part of the GNU C Library. Contributed by Paul Eggert (eggert@twinsun.com). - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ /* Define this to have a standalone program to test this implementation of mktime. */ @@ -109,14 +107,6 @@ const unsigned short int __mon_yday[2][13] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; -static struct tm *ranged_convert __P ((struct tm *(*) __P ((const time_t *, - struct tm *)), - time_t *, struct tm *)); -static time_t ydhms_tm_diff __P ((int, int, int, int, int, const struct tm *)); -time_t __mktime_internal __P ((struct tm *, - struct tm *(*) (const time_t *, struct tm *), - time_t *)); - #ifdef _LIBC # define my_mktime_localtime_r __localtime_r @@ -124,7 +114,6 @@ time_t __mktime_internal __P ((struct tm *, /* If we're a mktime substitute in a GNU program, then prefer localtime to localtime_r, since many localtime_r implementations are buggy. */ -static struct tm *my_mktime_localtime_r __P ((const time_t *, struct tm *)); static struct tm * my_mktime_localtime_r (const time_t *t, struct tm *tp) { @@ -172,23 +161,6 @@ ydhms_tm_diff (int year, int yday, int hour, int min, int sec, } } - -static time_t localtime_offset; - -/* Convert *TP to a time_t value. */ -time_t -mktime (struct tm *tp) -{ -#ifdef _LIBC - /* POSIX.1 8.1.1 requires that whenever mktime() is called, the - time zone names contained in the external variable `tzname' shall - be set as if the tzset() function had been called. */ - __tzset (); -#endif - - return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset); -} - /* Use CONVERT to convert *T to a broken down time in *TP. If *T is out of range for conversion, adjust it so that it is the nearest in-range value and then convert that. */ @@ -389,6 +361,24 @@ __mktime_internal (struct tm *tp, return t; } + +static time_t localtime_offset; + +/* Convert *TP to a time_t value. */ +time_t +mktime (tp) + struct tm *tp; +{ +#ifdef _LIBC + /* POSIX.1 8.1.1 requires that whenever mktime() is called, the + time zone names contained in the external variable `tzname' shall + be set as if the tzset() function had been called. */ + __tzset (); +#endif + + return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset); +} + #ifdef weak_alias weak_alias (mktime, timelocal) #endif