timezone printing in date messed up?

perryh at pluto.rain.com perryh at pluto.rain.com
Sat Nov 3 21:38:43 PDT 2007


> > > OS X Leopard has the same bug ...
> > 
> > How did you test it in Leopard?  I tried it in Tiger, intending
> > to contribute another data point, and I got:
>
> Leopard's /bin/date accepts -j.  You can try compiling FreeBSD
> date on Tiger.

I had decided against that, since it would propagate the bug if
it happened to be in the FreeBSD /bin/date.  It turns out the
output conversion can be tested using -r:

for a in 0 1 2 3 4 5 6 7 8 9 10 11 12
do
  date -r `expr 1194163200 + 600 \* $a`
done

and this gives correct results in both Tiger and 6.1:

Sun Nov  4 01:00:00 PDT 2007
Sun Nov  4 01:10:00 PDT 2007
Sun Nov  4 01:20:00 PDT 2007
Sun Nov  4 01:30:00 PDT 2007
Sun Nov  4 01:40:00 PDT 2007
Sun Nov  4 01:50:00 PDT 2007
Sun Nov  4 01:00:00 PST 2007
Sun Nov  4 01:10:00 PST 2007
Sun Nov  4 01:20:00 PST 2007
Sun Nov  4 01:30:00 PST 2007
Sun Nov  4 01:40:00 PST 2007
Sun Nov  4 01:50:00 PST 2007
Sun Nov  4 02:00:00 PST 2007

but the original command, run in 6.1, exhibits the bug:

for a in 0 1 2 3 4 5 6 7 8 9 10 11 12
do
  date -j -f %s `expr 1194163200 + 600 \* $a`
done

Sun Nov  4 01:00:00 PDT 2007
Sun Nov  4 01:10:00 PDT 2007
Sun Nov  4 01:20:00 PDT 2007
Sun Nov  4 01:30:00 PST 2007
Sun Nov  4 01:40:00 PST 2007
Sun Nov  4 01:50:00 PST 2007
Sun Nov  4 01:00:00 PDT 2007
Sun Nov  4 01:10:00 PDT 2007
Sun Nov  4 01:20:00 PDT 2007
Sun Nov  4 01:30:00 PST 2007
Sun Nov  4 01:40:00 PST 2007
Sun Nov  4 01:50:00 PST 2007
Sun Nov  4 02:00:00 PST 2007

Maybe this helps someone familiar with the internals of /bin/date
fix it in time for next fall :)


More information about the freebsd-hackers mailing list