bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

date misbehaves with illegal timezones


From: Juergen Weigert
Subject: date misbehaves with illegal timezones
Date: Mon, 19 Sep 2005 20:09:25 +0200

Hi coreutils people!

Guessing timezones with date is dangerous.
What is the time in the US, say, Mountain area?

$ env TZ=US/Mountain date
Mon Sep 19 11:51:28 MDT 2005
--> correct.

$ env TZ=MST date
Mon Sep 19 10:51:58 MST 2005
--> correct.

Aha, difference between MDT and MST is one hour. 
Let us check that with the abbreviated name, as seen above:

$ env TZ=MDT date
Mon Sep 19 17:52:53 MDT 2005
--> wrong.

Oops, now difference is 7 hours ...
The problem here is, that MDT is an unknown timezone on my machine.
Date silently defaults back to GMT, but it keeps the label 'MDT'.

The first bug here may be that env TZ=US/Mountain date prints a timezone
name that it cannot use as its own input. I don't want to fix that now.

The second and IMHO more serious bug is that invalid input is not 
recognized as such, and thus very misleading output is generated.

Please find attached a trivial patch that checks for unknown 
timezones and prints a warning. I should also change the printed label 
in that case, but I don't see an easy way to do that.

        thanks,
                Jw.

-- 
 o \  Juergen Weigert  paint it green! __/ _=======.=======_
<V> | address@hidden       wide open suse_/        _---|____________\/
 \  | 0911 74053-508         (tm)__/          (____/            /\
(/) | __________________________/             _/ \_ vim:set sw=2 wm=8

Attachment: coreutils-cvs-date-tzname-check.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]