lib/mktime.c


Log

Author Commit Date CI Message
Paul Eggert 8b2c2981 2003-09-09T22:41:13 Remove K&R cruft.
Paul Eggert 7b224479 2003-09-06T21:34:07 Add time_r module. Change timegm, mktime, and strftime to use localtime_r and gmtime_r, now supplied by the time_r module. This fixes some timegm bugs and cleans up mktime and strftime a bit.
Paul Eggert c80984f8 2003-07-07T23:11:52 Fix some boundary cases and remove need for floating point. 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.
Paul Eggert bea5a055 2003-06-05T20:07:59 Assume freestanding C89 or better. (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.
Paul Eggert b2c42615 2003-06-05T06:43:15 Fix Debian bug 177940 <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.
Paul Eggert a76a349e 2003-06-04T20:09:47 Ensure we use gnulib mktime rather than glibc's mktime, on hosts where mktime isn't the inverse of localtime (negative time_t).
Karl Berry 54a64110 2003-05-30T15:06:41 mktime update from libc
Paul Eggert 3b59684c 2003-05-28T20:18:22 (__mktime_internal): Do not reject negative timestamps arbitrarily.
Jim Meyering 41d8937a 2002-11-25T15:31:05 Really sync with libc, not with my locally-modified copy. Thanks, Karl!
Jim Meyering 1bc47090 2002-11-25T13:22:20 Sync from libc, now that it has the latest fix.
Jim Meyering fd8e762e 2002-11-24T10:39:54 Merge in changes from libc.
Jim Meyering 9d7d2eaf 2002-11-24T10:06:16 Avoid a link-time failure on some Linux systems. (STATIC): Define to be empty (_LIBC) or `static' (otherwise). (__mon_yday): Declare with the STATIC attribute. (__mktime_internal): Likewise.
Jim Meyering 89f2b489 2000-08-07T15:48:18 back out Copyright date changes for files with no changes year
Jim Meyering d349992d 2000-07-09T07:22:43 update copyright date
Jim Meyering b0aca2f6 1999-02-17T14:58:41 tweak comment
Jim Meyering f979eb04 1999-02-16T21:35:48 new version from Uli
Jim Meyering 7f20e762 1999-01-19T04:47:24 (__mktime_internal): Adopt the traditional (and problematic) notion of what to do when tm_isdst doesn't match. From Paul Eggert.
Jim Meyering cf42d3e5 1998-12-07T03:12:10 ansideclify
Jim Meyering d37eda27 1998-10-18T14:08:35 Don't invoke localtime_r or gmtime_r unless it's the GNU C 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.
Jim Meyering 6579bcf6 1998-10-18T01:10:21 Declare localtime_r if necessary.
Jim Meyering 184e8608 1998-10-17T12:39:30 Some systems require <unistd.h> to be included before <time.h> for localtime_r to be declared properly.
Jim Meyering 599729fb 1998-10-12T02:00:59 (_REENTRANT): Define again -- linux-2.0.33 needs it.
Jim Meyering a5382999 1998-10-11T23:03:41 (__mktime_internal): When the requested time falls 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.
Jim Meyering c5da3fd9 1998-10-08T12:19:48 (my_mktime_localtime_r): Renamed from localtime_r. 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 Meyering 0eeff3be 1998-04-12T15:16:37 .
Jim Meyering 96462d30 1998-04-12T09:39:30 (TYPE_MAXIMUM): Update from system.h.
Jim Meyering 9300fc8b 1998-02-24T23:19:13 add comment
Jim Meyering bfd921d6 1998-01-23T22:02:54 (__mktime_internal): Work around bug in Irix4.0.5's C compiler. From Kaveh Ghazi. (TYPE_MINIMUM): Define. (TYPE_MAXIMUM): Define. (TIME_T_MIN): Use TYPE_MINIMUM. (TIME_T_MAX): Use TYPE_MAXIMUM.
Jim Meyering fd396561 1997-11-18T03:32:00 (_REENTRANT): #define, as some hosts need this to declare localtime_r properly. From Paul Eggert.
Jim Meyering 1873f591 1997-11-13T13:22:54 Update from FSF.
Jim Meyering 89b2adc0 1997-09-17T12:46:45 update from FSF .../copies
Jim Meyering 068f1a3a 1997-03-14T03:28:09 (TIME_T_MIN): Work around a bug in Cray C 5.0.3.0.
Jim Meyering 77d822a7 1997-02-21T02:16:54 update from FSF
Jim Meyering 1631b5c0 1996-11-05T04:22:40 Fix copyright.
Jim Meyering 6d8337bf 1996-07-15T03:36:16 update FSF address in copyright
Jim Meyering 870b659d 1995-11-03T19:56:08 New version from glibc.
Jim Meyering 2c5d56e2 1994-09-27T22:02:08 merge with 1.10n2
Jim Meyering c9aad3a0 1994-08-19T22:42:32 merge with 1.10g
Jim Meyering 8965f456 1994-07-26T04:06:26 merge with 1.10f
Jim Meyering 6a75c0b2 1994-02-12T17:23:51 merge with 1.9.2i
Jim Meyering 43e78b97 1992-11-01T05:44:30 Initial revision