bug-cvs
[Top][All Lists]
Advanced

[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)

-----BEGIN PGP SIGNED MESSAGE-----
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
year.

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    
autobuild@tgm.daemon.org:/autobuild/netbsd-1-6/i386/OBJ/autobuild/netbsd-1-6/src/sys/arch/i386/compile/GENERIC
i386
bash-2.05$ TZ=Asia/Calcutta date +%Z
IST
bash-2.05$ TZ=Asia/Unrecognized date +%Z
GMT
bash-2.05$



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.  :)

Regards,

Derek


# 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'
returns
# 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
understands
# 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)
supported
# 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
system"
                return `false`
        else
                return `:`
        fi
}

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

iD8DBQFCYC6rLD1OTBfyMaQRAscSAJ9xZwcRRIYLWX9QMCK24xeJBwbOWACg702O
nsxY3Z0u7Xirj0FQ1iAtULk=
=f3sm
-----END PGP SIGNATURE-----






reply via email to

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