Bug in GNU date

Niall O Broin <[email protected]>
Newsgroups gmane.comp.gnu.sh-utils.bugs
Message-ID <[email protected]>
There is a bug in GNU date which manifests itself when TZ has no value in
the environment. See transcript below:

niall@bagend:~ >echo $TZ

niall@bagend:~ >for day in mon tues wednes thurs fri satur sun
do date -d "last ${day}day"
done
Mon Apr  1 00:00:00 IST 2002
Tue Apr  2 00:00:00 IST 2002
Wed Apr  3 00:00:00 IST 2002
Wed Mar 27 23:00:00 GMT 2002
Thu Mar 28 23:00:00 GMT 2002
Fri Mar 29 23:00:00 GMT 2002
Sat Mar 30 23:00:00 GMT 2002

niall@bagend:~ >export TZ=GMT
niall@bagend:~ >date
Thu Apr  4 14:14:30 GMT 2002
niall@bagend:~ >for day in mon tues wednes thurs fri satur sun
do date -d "last ${day}day"
done
Mon Apr  1 00:00:00 GMT 2002
Tue Apr  2 00:00:00 GMT 2002
Wed Apr  3 00:00:00 GMT 2002
Thu Mar 28 00:00:00 GMT 2002
Fri Mar 29 00:00:00 GMT 2002
Sat Mar 30 00:00:00 GMT 2002
Sun Mar 31 00:00:00 GMT 2002

niall@bagend:~ >export TZ=IST
niall@bagend:~ >for day in mon tues wednes thurs fri satur sun
do date -d "last ${day}day"
done
Mon Apr  1 00:00:00 IST 2002
Tue Apr  2 00:00:00 IST 2002
Wed Apr  3 00:00:00 IST 2002
Thu Mar 28 00:00:00 IST 2002
Fri Mar 29 00:00:00 IST 2002
Sat Mar 30 00:00:00 IST 2002
Sun Mar 31 00:00:00 IST 2002

niall@bagend:~ >export TZ=
niall@bagend:~ >for day in mon tues wednes thurs fri satur sun; do date -d
"last ${day}day"; done
Mon Apr  1 00:00:00 UTC 2002
Tue Apr  2 00:00:00 UTC 2002
Wed Apr  3 00:00:00 UTC 2002
Thu Mar 28 00:00:00 UTC 2002
Fri Mar 29 00:00:00 UTC 2002
Sat Mar 30 00:00:00 UTC 2002
Sun Mar 31 00:00:00 UTC 2002


I have verified this with several distributions of Gnu/Linux, all of which
used sh-utils 2.0. I got and compiled 2.0.11 from alpha.gnu.org and the bug
persists in this version.


Kindest regards,


Niall  O Broin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.