[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in date (GNU sh-utils) 2.0
From: |
Zvi Har'El |
Subject: |
Re: Bug in date (GNU sh-utils) 2.0 |
Date: |
Wed, 20 Jun 2001 17:53:36 +0300 (IDT) |
Hi,
I realized the bug is in sh-utils-2.0/lib/getdate.y . Diffing it with
fileutils-4.1/lib/getdate.y, I got
--- fileutils-4.1/lib/getdate.y Sun Apr 8 22:00:26 2001
+++ sh-utils-2.0/lib/getdate.y Sat Aug 7 12:39:05 1999
[many lines deleted]
}
else
{
tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
}
-
- /* Let mktime deduce tm_isdst if we have an absolute time stamp,
- or if the relative time stamp mentions days, months, or years. */
- if (pc.dates_seen | pc.days_seen | pc.times_seen | pc.rel_day
- | pc.rel_month | pc.rel_year)
+ tm.tm_hour += yyRelHour;
+ tm.tm_min += yyRelMinutes;
+ tm.tm_sec += yyRelSeconds;
+
+ /* Let mktime deduce tm_isdst if we have an absolute timestamp,
+ or if the relative timestamp mentions days, months, or years. */
+ if (yyHaveDate | yyHaveDay | yyHaveTime | yyRelDay | yyRelMonth | yyRelYear)
tm.tm_isdst = -1;
- /* But if the input explicitly specifies local time with or without
- DST, give mktime that information. */
- if (pc.local_zones_seen)
- tm.tm_isdst = pc.local_isdst;
-
tm0 = tm;
Start = mktime (&tm);
The main point is the bottom paragraph: "But if the input explicitly specifies
local time with or without DST, give mktime that information". This is missing
in the sh-utils version!!! The patch is not trivial since the latter version
doesn't have a local_isdst variable. However, just take the fileutil version,
which is "Modified by Paul Eggert <address@hidden> in August 1999 to do
the right thing about local DST", and plug it into the sh-util distrib!
> Hi,
>
> I am afraid I stumbled on a bug in date (GNU sh-utils) 2.0, running on RedHat
> 7.1 (RPM sh-utils-2.0-13) or Solaris 2.6 (installed from sources in
> sh-utils-2.0.tar.gz). When trying to convert seconds since the epoch to
> readable date (following the examples in the info file) I got
>
> $ TZ=Asia/Jerusalem date -u -d "1970-01-01 UTC `date +%s` sec";date -u
> Wed Jun 20 11:04:14 UTC 2001
> Wed Jun 20 10:04:15 UTC 2001
>
> $ TZ=+0300 date -u -d "1970-01-01 UTC `date +%s` sec";date -u
> Wed Jun 20 10:04:57 UTC 2001
> Wed Jun 20 10:04:57 UTC 2001
>
> The result shouldn't depend on the TZ at all. The second behavior is correct,
> The first, incorrect behavior happens in variations for different cities,
> i.e.,
>
> $ TZ=America/Anchorage date -u -d "1970-01-01 UTC `date +%s` sec";date -u
> Wed Jun 20 12:10:05 UTC 2001
> Wed Jun 20 10:10:05 UTC 2001
>
> The incorrect behavior doesn't happen with date (GNU sh-utils) 1.16, which I
> have installed on a RedHat 5.2 machine (RPM sh-utils-1.16-14). I also was not
> able to replicate it on a Solaris 2.8 machine on which I installed date (GNU
> sh-utils) 2.0 from sources.
>
> Sincerely,
>
> Zvi.
>
>
--
Dr. Zvi Har'El mailto:address@hidden Department of Mathematics
tel:+972-54-227607 Technion - Israel Institute of Technology
fax:+972-4-8324654 http://www.math.technion.ac.il/~rl/ Haifa 32000, ISRAEL
"If you can't say somethin' nice, don't say nothin' at all." -- Thumper (1942)
Wednesday, 29 Sivan 5761, 20 June 2001, 5:36PM