[Top][All Lists]

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

Re: get_date returning false

From: Derek Price
Subject: Re: get_date returning false
Date: Fri, 15 Apr 2005 17:14:19 -0400
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Hash: SHA1

Mark D. Baushke wrote:

> So, for unrecognized zones, three spaces are produced for the
> timezone on the CRAY Y-MP system.

Hrm.  `date +%Z' returns `GMT' on my NetBSD 1.6.1.  I think this will
not be easy, especially as one of the timezones suggested by Ian's
tests was Europe/London, which really _does_ fall into GMT part of the

bash-2.05$ uname -a
NetBSD strength.ximbiot.com 1.6.1 NetBSD 1.6.1 (GENERIC) #0: Tue Apr
8 12:05:52 UTC 2003    
bash-2.05$ TZ=Asia/Calcutta date +%Z
bash-2.05$ TZ=Asia/Unrecognized date +%Z

Okay, I came up with and committed the attached.  Run on platforms
where `TZ=Unrecognized date +%Z' returns `GMT' yet `Europe/London' is
a recognized timezone, like NetBSD, it will skip one set of tests
during portions of the year when Europe/London is in GMT, but the
tests should run or be skipped properly on other platforms and in the
summer on BSD.

If anyone thinks it is worth spending more time on this, they are
welcome to do so.  :)



# Prep for future calls to valid_timezone().
# This should set $UTZ to three spaces, `GMT',
`Unrecognized/Unrecognized', or
# possibly the empty string, depending on what system we are running
on.  With
# any luck, this will catch any other existing variations as well.
The way it
# is used later does have the disadvantage of rejecting at least the
# `Europe/London' timezone for half the year when $UTZ gets set to
`GMT', like
# happens on NetBSD, but, since I haven't come up with any better
ideas and
# since rejecting a timezone just causes a few tests to be skipped,
this will
# have to do for now.
# UTZ stands for Unrecognized Time Zone.
UTZ=`TZ=Unrecognized/Unrecognized date +%Z`

# The following function will return true if $1 is a valid timezone.
It will
# return false and set $skipreason, otherwise.
# Clobbers $NTZ & $skipreason.
# SUS2 says `date +%Z' will return `no characters' if `no timezone is
# determinable'.  It is, unfortunately, not very specific about what
# `determinable' means.  On GNU/Linux, `date +%Z' returns $TZ when $TZ
is not
# recognized.  NetBSD 1.6.1 "determines" that an unrecognizable value
in $TZ
# really means `GMT'.  On Cray, the standard is ignored and `date +%Z'
# three spaces when $TZ is not recognized.  We test for all three
cases, plus
# the empty string for good measure, though I know of no set of conditions
# which will actually cause `date +%Z' to return the empty string SUS2
# specifies.
# Due to the current nature of this test, this will not work for the
# three-letter zone codes on some systems.  e.g.:
#       test `TZ=EST date +%Z` = "EST"
# should, quite correctly, evaluate to true on most systems, but:
#       TZ=Asia/Calcutta date +%Z
# would return `IST' on GNU/Linux, and hopefully any system which
# the `Asia/Calcutta' timezone, and `   ' on Cray.  Similarly:
#       TZ=Doesnt_Exist/Doesnt_Exist date +%Z
# returns `Doesnt_Exist/Doesnt_Exist' on GNU/Linux and `   ' on Cray.
# Unfortunately, the %z date format string (-HHMM format time zone)
# by the GNU `date' command is not part of any standard I know of and,
# therefore, is probably not portable.
valid_timezone ()
        NTZ=`TZ=$1 date +%Z`
        if test "$NTZ" = "$UTZ" || test "$NTZ" = "$1"; then
                skipreason="$1 is not a recognized timezone on this
                return `false`
                return `:`

Version: GnuPG v1.4.0 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org


reply via email to

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