Note: patch is included!

1. Conversion of Last-Modified time to time_t in http.c works
wrongly when DST is active -- t.tm_isdst should always be 0.

2. mktime_from_utc() from http.c is too complicated.
It's so complicated that "Gurus from CISCO" didn't notice that
the following line:
    return (tl <= tb ? (tl + (tl - tb)) : (tl - (tb - tl)));
is equivalent to:
    return tl+tl-tb;
This patch contains even more simple solution.

3. Code for FTP timestamps is probably broken too (I haven't reviewed it carefully).
It's unclear to me if the timezone of modification times of files presented by FTP 
servers
is UTC
or local. I couldn't find it in any RFC, but I know that my wu-ftpd uses UTC.

4. In case guys from RedHat haven't submitted their patches,
I'd like you to know there are some to make use of in wget-1.6-2.src.rpm.

Artur Zaprzala
Conversion of Last-Modified time to time_t in http.c works
wrongly when DST is active -- t.tm_isdst should always be 0.

mktime_from_utc() from http.c is too complicated.
It's so complicated that Gurus from CISCO didn't notice that
the following line:
    return (tl <= tb ? (tl + (tl - tb)) : (tl - (tb - tl)));
is equivalent to:
    return tl+tl-tb;
This patch contains even more simple solution.


In case guys from RedHat haven't submitted their patches,
I'd like to tell you there are some in wget-1.6-2.src.rpm.

--- wget-1.6/src/http.c-orig    Sun Dec 31 04:47:58 2000
+++ wget-1.6/src/http.c Wed May  2 22:03:28 2001
@@ -1332,18 +1332,13 @@
 /* Converts struct tm to time_t, assuming the data in tm is UTC rather
    than local timezone (mktime assumes the latter).
 
-   Contributed by Roger Beeman <[EMAIL PROTECTED]>, with the help of
-   Mark Baushke <[EMAIL PROTECTED]> and the rest of the Gurus at CISCO.  */
+   Contributed by Artur Zaprzala <[EMAIL PROTECTED]>.  */
 static time_t
 mktime_from_utc (struct tm *t)
 {
-  time_t tl, tb;
-
-  tl = mktime (t);
-  if (tl == -1)
-    return -1;
-  tb = mktime (gmtime (&tl));
-  return (tl <= tb ? (tl + (tl - tb)) : (tl - (tb - tl)));
+  time_t tt = mktime(t);
+  if (tt == -1) return -1;
+  return tt-timezone;  /* mktime assumes localtime, so we need to adjust */
 }
 
 /* Check whether the result of strptime() indicates success.
@@ -1398,10 +1393,8 @@
      needs initialization is tm_isdst, since the others will be set by
      strptime.  Since strptime does not set tm_isdst, it will return
      the data structure with whatever data was in tm_isdst to begin
-     with.  For those of us in timezones where DST can occur, there
-     can be a one hour shift depending on the previous contents of the
-     data area where the data structure is allocated."  */
-  t.tm_isdst = -1;
+     with.  Timestamp is in UTC, so DST does not occur."  */
+  t.tm_isdst = 0;
 
   /* Note that under foreign locales Solaris strptime() fails to
      recognize English dates, which renders this function useless.  I

Reply via email to