summaryrefslogtreecommitdiff
path: root/lib/mktime.c
Commit message (Collapse)AuthorAgeFilesLines
* mktime.c: normalize tp->tm_isdst value to -1/0/1.Ulrich Drepper2008-07-231-1/+3
| | | | | | * lib/mktime.c (__mktime_internal): Normalize tp->tm_isdst value. Reported by Michael Ringe <Michael.Ringe@gmx.de> in <http://sourceware.org/bugzilla/show_bug.cgi?id=6723>.
* New module 'time', so that apps can include <time.h> as perPaul Eggert2007-02-121-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX and GNU instead of separate include files like time_r.h and timegm.h. This implementation tries out a simpler approach for replacing decls in standard include files (as compared to the string module), somewhat as an experiment. * config/srclist.txt: Comment out mktime.c for now. * doc/gnulib-tool.texi (Initial import): Don't use time_r as an example since it doesn't apply any more. Use generic wording instead. * MODULES.html.sh (Support for systems lacking POSIX:2001): New module 'time'. * lib/time_.h, m4/time_h.m4, modules/time: New files. * lib/strptime.h, lib/time_r.h, lib/timegm.h: Remove. * lib/mktime.c: Include config.h depending on _LIBC, not HAVE_CONFIG_H. Don't include <sys/types.h>; no longer needed since we assume C89. * lib/mktime.c: Don't include "time_r.h"; no longer needed. * lib/strftime.c: Likewise. * lib/time_r.c: Likewise. * lib/nanosleep.c (nanosleep): #undef after include files, not before. * lib/nanosleep.c: Include <time.h> first, to check interface. * lib/strptime.c: Likewise. * lib/time_r.c: Likewise. * lib/timegm.c: Likewise. * lib/strptime.c: Don't include strptime.h or time_r.h; no longer needed. * lib/timegm.c: Don't include timegm.h; no longer needed. * lib/timespec.h: Don't include <sys/time.h> before <time.h>; time.h now handles any problems in that area. (struct timespec, nanosleep): Remove; time.h now arranges for these. * lib/xnanosleep.c: Don't include timespec.h; no longer needed now that time.h defines struct timespec. * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Check that nanosleep is declared. Set REPLACE_NANOSLEEP. Don't AC_DEFINE nanosleep; the time module now handles that. * m4/strptime.m4 (gl_FUNC_STPRTIME): Set REPLACE_STRPTIME. * m4/time_r.m4 (gl_TIME_R): Don't define HAVE_TIME_R_POSIX; no longer needed. Set REPLACE_LOCALTIME. * m4/timegm.m4 (gl_FUNC_TIMEGM): Set REPLACE_TIMEGM. * m4/timespec.m4 (gl_CHECK_TYPE_STRUCT_TIMESPEC): Move to time_h.m4. (gl_TIMESPEC): Don't check for sys/time.h or struct timespec or nanosleep; time_h.m4 now does that. Don't require gl_USE_SYSTEM_EXTENSIONS; no longer needed directly, and the time module handles this now. * modules/getdate (Depends-on): Remove timespec. Add time. * modules/nanosleep (Depends-on): Likewise. * modules/stat-time (Depends-on): Likewise. * modules/nanosleep (Include): Include time.h, not timespec.h. * modules/strptime (Files): Remove lib/strptime.h. (Depends-on): Add extensions, time. (Include): Include time.h, not strptime.h. * modules/time_r (Files): Remove lib/time_r.h. (Depends-on): Add time. (Include): Include time.h, not time_r.h. * modules/timegm: Likewise. * modules/timespec (Description): Now does timespec-related decls of our own, instead of struct timespec itself. (Depends-on): Add time; remove extensions. (Maintainer): Add self. * modules/utimecmp (Depends-on): Add time; remove timespec. * modules/utimens (Depends-on): Likewise. * modules/xnanosleep (Depends-on): Likewise.
* autoupdateKarl Berry2006-09-111-2/+2
|
* * config/srclist.txt: Temporarily comment out mktime.c until glibc bugPaul Eggert2006-09-081-4/+5
| | | | | | | | | | | | | | | | | | | | | | | 2821 is fixed. * lib/mktime.c (guess_time_tm): Fix bug where mktime returned the maximum time_t value rather than (time_t) -1. Problem originally reported by William Bardwell <http://sourceware.org/bugzilla/show_bug.cgi?id=2821>. * m4/mktime.m4 (AC_FUNC_MKTIME): Sync from Autoconf. Check for unistd.h too, since Autoconf doesn't assume POSIX. Also: 2006-09-08 Paul Eggert <eggert@cs.ucla.edu> Add year_2050_test to catch glibc bug 2821 <http://sourceware.org/bugzilla/show_bug.cgi?id=2821>. 2006-08-15 Paul Eggert <eggert@cs.ucla.edu> Prefer #ifdef to #if. 2006-04-02 Paul Eggert <eggert@cs.ucla.edu> Return from 'main' instead of calling 'exit'.
* srclist.updateKarl Berry2005-09-181-2/+1
|
* * mktime.c: Include <string.h> even if !DEBUG. (From glibc.)Paul Eggert2005-06-231-13/+10
| | | | | | | | | (ranged_convert): Don't save conversion in a temporary struct. This causes a warning with GCC 4.0.0, and anyway in the typical case it's not worth the extra 100 bytes or so of code. (ranged_convert, __mktime_internal): When calling a function via a pointer P, use P () rather than (*P) (), as we now assume C89 or better.
* *** empty log message ***Paul Eggert2005-05-141-1/+1
|
* Propagate intprops.h comment fixes to mktime.c and strftime.c.Paul Eggert2005-03-261-3/+3
|
* * mktime.c (TYPE_TWOS_COMPLEMENT, TYPE_ONES_COMPLEMENT,Paul Eggert2005-03-151-10/+20
| | | | | | TYPE_SIGNED_MAGNITUDE, TYPE_MINIMUM, TYPE_MAXIMUM): Sync from intprops.h. * strtol.c: Likewise.
* Factor int-properties macros into a single file, except forPaul Eggert2005-03-091-8/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | glibc-related files. * lib/intprops.h: New file. * lib/getloadavg.c: Include it instead of limits.h. (INT_STRLEN_BOUND): Remove. * lib/human.c: Include intprops.h. (group_number): Use INT_STRLEN_BOUND instead of rolling it ourself. * lib/human.h (LONGEST_HUMAN_READABLE): Use 146/485 rather than 302/1000. * lib/inttostr.h: Include intprops.h instead of limits.h. (INT_STRLEN_BOUND, INT_BUFSIZE_BOUND): Remove. * lib/mktime.c (TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT): New macros, for consistency with intprops.h. (time_t_is_integer, twos_complement_arithmetic): Use them. * lib/sig2str.h: Include <signal.h>, intprops.h. (INT_STRLEN_BOUND): Remove. * lib/strftime.c (TYPE_SIGNED): Remove. (INT_STRLEN_BOUND): Switch to same implementation as intprops.h. * lib/strtol.c: Adjust comments to match intprops.h. * lib/userspec.c: Include intprops.h. (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove. * lib/utimecmp.c, lib/xnanosleep.c, lib/xstrtol.c: Likewise. * lib/utimecmp.c (utimecmp): Use TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT instead of rolling our own expressions. * lib/xstrtol.c: Include xstrtol.h first, to test interface. * modules/getloadavg (Files): Add lib/intprops.h. * modules/human (Files): Likewise. * modules/inttostr (Files): Likewise. * modules/sig2str (Files): Likewise. * modules/userspec (Files): Likewise. * modules/utimecmp (Files): Likewise. * modules/xnanosleep (Files): Likewise. * modules/xstrtol (Files): Likewise.
* autoupdateKarl Berry2005-03-081-2/+3
|
* (__mktime_internal): If SEC_REQUESTED != SEC,Paul Eggert2004-12-031-1/+2
| | | | convert T2, not T. (Imported from libc.)
* (SHR): New macro, which is a portablePaul Eggert2004-11-111-15/+31
| | | | | | | substitute for >> that should work even on Crays. (TIME_T_MIDPOINT, ydhms_diff, __mktime_internal): Use it. Problem reported by Mark D. Baushke in <http://lists.gnu.org/archive/html/bug-gnulib/2004-11/msg00071.html>.
* (not_equal_tm): Remove redundant check.Paul Eggert2004-10-271-1/+0
|
* (leapyear): Arg is long int, not int.Paul Eggert2004-10-221-1/+1
|
* (__mktime_internal) [!_LIBC]: Define to mktime_internalJim Meyering2004-01-211-2/+4
| | | | | so as not to conflict with a different-sized __mktime_internal function in GNU libc.
* Remove K&R cruft.Paul Eggert2003-09-091-9/+3
|
* Add time_r module. Change timegm, mktime, and strftime to use localtime_rPaul Eggert2003-09-061-20/+10
| | | | | and gmtime_r, now supplied by the time_r module. This fixes some timegm bugs and cleans up mktime and strftime a bit.
* Fix some boundary cases and remove need for floating point.Paul Eggert2003-07-071-133/+255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue a compile-time diagnostic if time_t is floating point, or if two's complement arithmetic is not in effect, or if arithmetic right shift does not propagate the sign. These assumptions were all in the original code but they weren't checked. (TIME_T_MIDPOINT, verify): New macros. (__isleap): Remove; it has integer overflow problems. (leapyear): New function, without those problems. (ydhms_tm_diff): Remove; splitting into two parts. (ydhms_diff): New function, containing the arithmetic part of the old ydhms_tm_diff function. Issue a compile-time diagnostic if we are not using C99 integer division. Avoid casts when possible. (guess_time_tm): New function, containing the checking part of the old ydhms_tm_diff function. Return the new value, rather than the difference between it and the old. Accept a new argument T so that *T specifies the old value. Check for overflow in the result. (__mktime_internal): Use a time_t offset, not a long int offset. This undoes the 2003-06-04 change, which is no longer needed now that we have better overflow checking. (localtime_offset): Likewise. (__mktime_internal): Avoid harmful overflow on hosts where time_t and long are 64-bit but int is only 32-bit. (ydhms_diff): Use long int to store year1 and yday1. Issue a compile-time diagnostic if long int is not wide enough. (__mktime_internal): Use long int to store adjusted year and yday. Use plain C rather than preprocessor commands, if that doesn't affect efficiency. Check for overflow (and try to repair) after each probe rather than checking only at the very end. This avoids some bugs (e.g., southern hemisphere, behind GMT, and GMT offset at minimum time does not equal GMT offset at maximum time). Use integer to check for overflow rather than floating point; this is more portable to non-IEEE hosts, and is a tad faster. When we detect that we are oscillating between two values, don't check whether tm_isdst has the requested value, since we already know the answer. When tm_isdst has the wrong value, use a different heuristic to find the right one, based on the extreme values actually observed in practice in tz2003a, rather than the (overly optimistic) "previous 3 calendar quarters". (not_equal_tm, print_tm, check_result): Use "const T" rather than "T const" to accommodate glibc style. (check_result): Use less-confusing report format. "long" -> "long int. (main): Likewise. Don't loop if the iteration overflows time_t. Allow a negative step in the iteration.
* Assume freestanding C89 or better.Paul Eggert2003-06-051-41/+9
| | | | | | | | | (HAVE_LIMITS_H): Remove. Assume it's 1. (__P): Remove; not used. (INT_MIN, INT_MAX): Remove; <limits.h> defines them. (mktime, not_equal_tm, print_tm, check_result, main): Use prototypes. Use const * where appropriate. (main): Fix typo in testing code that uncovered by above changes.
* Fix Debian bug 177940Paul Eggert2003-06-051-3/+6
| | | | | | | | <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=177940>. (localtime_offset): Now long int, not time_t, because we want it to be guaranteed to be signed. All uses changed. (__mktime_internal): If overflow would occur when adding offset, don't add it.
* Ensure we use gnulib mktime rather than glibc's mktime, on hostsPaul Eggert2003-06-041-15/+1
| | | | where mktime isn't the inverse of localtime (negative time_t).
* mktime update from libcKarl Berry2003-05-301-12/+25
|
* (__mktime_internal): Do not reject negative timestamps arbitrarily.Paul Eggert2003-05-281-15/+1
|
* Really sync with libc, not with my locally-modified copy.Jim Meyering2002-11-251-3/+0
| | | | Thanks, Karl!
* Sync from libc, now that it has the latest fix.Jim Meyering2002-11-251-2/+8
|
* Merge in changes from libc.Jim Meyering2002-11-241-6/+34
|
* Avoid a link-time failure on some Linux systems.Jim Meyering2002-11-241-11/+14
| | | | | | (STATIC): Define to be empty (_LIBC) or `static' (otherwise). (__mon_yday): Declare with the STATIC attribute. (__mktime_internal): Likewise.
* back out Copyright date changes for files with no changes yearJim Meyering2000-08-071-1/+1
|
* update copyright dateJim Meyering2000-07-091-1/+1
|
* tweak commentJim Meyering1999-02-171-1/+1
|
* new version from UliJim Meyering1999-02-161-41/+31
|
* (__mktime_internal): Adopt the traditional (andJim Meyering1999-01-191-21/+25
| | | | | problematic) notion of what to do when tm_isdst doesn't match. From Paul Eggert.
* ansideclifyJim Meyering1998-12-071-16/+9
|
* Don't invoke localtime_r or gmtime_r unless it's the GNU CJim Meyering1998-10-181-30/+7
| | | | | | | | | | library's localtime_r and gmtime_r; there are too many buggy implementations of localtime_r and gmtime_r out there, and it's not worth keeping track of all the different bugs. * mktime.c (__EXTENSIONS__, HAVE_LOCALTIME_R): Remove. (my_mktime_localtime_r): Renamed from localtime_r; all uses changed. Base it on localtime unless _LIBC.
* Declare localtime_r if necessary.FILEUTILS-4_0-b4Jim Meyering1998-10-181-6/+5
|
* Some systems require <unistd.h> to be included before <time.h> forJim Meyering1998-10-171-9/+10
| | | | localtime_r to be declared properly.
* (_REENTRANT): Define again -- linux-2.0.33 needs it.Jim Meyering1998-10-121-1/+6
|
* (__mktime_internal): When the requested time fallsJim Meyering1998-10-111-11/+23
| | | | | | | | in a spring-forward gap of size DT, return a time that is DT away from the requested time, preferring a time whose tm_isdst differs from the requested value. Bump the max number of probes from 4 to 6 to account for the extra probes needed to discover a spring-forward gap in the worst case.
* (my_mktime_localtime_r): Renamed from localtime_r.Jim Meyering1998-10-081-6/+17
| | | | | | Define also if HAVE_LOCALTIME_R && defined (localtime_r), with a body that merely expands localtime_r; this works around a bug in Digital Unix 4.0A and 4.0D.
* .Jim Meyering1998-04-121-1/+1
|
* (TYPE_MAXIMUM): Update from system.h.Jim Meyering1998-04-121-1/+1
|
* add commentJim Meyering1998-02-241-1/+2
|
* (__mktime_internal): Work around bug in Irix4.0.5'sJim Meyering1998-01-231-9/+22
| | | | | | | | C compiler. From Kaveh Ghazi. (TYPE_MINIMUM): Define. (TYPE_MAXIMUM): Define. (TIME_T_MIN): Use TYPE_MINIMUM. (TIME_T_MAX): Use TYPE_MAXIMUM.
* (_REENTRANT): #define, as some hosts need this to declare localtime_r properly.Jim Meyering1997-11-181-0/+5
| | | | From Paul Eggert.
* Update from FSF.Jim Meyering1997-11-131-68/+153
|
* update from FSF .../copiesJim Meyering1997-09-171-1/+1
|
* (TIME_T_MIN): Work around a bug in Cray C 5.0.3.0.Jim Meyering1997-03-141-2/+4
|
* update from FSFJim Meyering1997-02-211-11/+33
|
* Fix copyright.Jim Meyering1996-11-051-16/+16
|