This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: A patch for mktime.c and tz*.c.


   From: hjl@lucon.org (H.J. Lu)
   Date: Fri, 6 Nov 1998 11:10:23 -0800 (PST)

   Paul's change looks ok. But I still don't like guessing unless we
   don't have a choice. For glibc 2, there is no need to guess with
   my patch.

Unfortunately, that patch appears to have a bug similar to one that
was in the Olson code had before 1995: it assumes that the DST offset
never changes.

This assumption is true for POSIX.1 TZ specifications, but it's false
for the Olson database.  For example, the first time that New Zealand
used DST, it used a 30-minute DST offset, and (from code inspection)
it appears that the patch will pick up this value and incorrectly
assume that New Zealand always uses a 30-minute DST offset.

This is an instance of a more general problem.  Given the current
mktime interface, mktime _must_ guess in some cases.  For example, how
much should mktime adjust 1989-01-01 00:00:00 with tm_isdst=1 in
Newfoundland, which used a 2-hour DST offset in summer 1988 and a
1-hour DST offset in summer 1989?  There's no way for mktime to know
whether a 2-hour or a 1-hour adjustment is correct.

The latest draft C9x proposes some interface changes to attack this
problem, but these changes have several problems and are likely to
be withdrawn.

Here's one way to attack this problem within the rules of the current
C Standard: have tm_isdst contain the DST offset, not just a binary
flag.  The C Standard and POSIX.1 allow this, but this change will
break some programs that incorrectly assume that a positive tm_isdst
is always either 0 or 1 (one of them being strftime.c itself!).  Also,
there is the tricky matter of representing negative DST (which POSIX.1
allows, though I believe that it has never happened in practice).  So
I would not advocate changing tm_isdst right now, as my impression is
that glibc is pretty close to release.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]