bug-cvs
[Top][All Lists]
Advanced

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

Re: get_date returning false


From: Mark D. Baushke
Subject: Re: get_date returning false
Date: Fri, 15 Apr 2005 15:04:44 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Derek,

Your script arrived here with linewrap problems... after I
fixed them, I get the following results with various boxes
I can access today...

I ran the attached script with three different arguments and
here are the results:

Timezone Tested    Result  Host (OS Release Hardware)
Asia/Calcutta      false   AIX 4.3 unknown
Europe/London      false   AIX 4.3 unknown
Pacific/Honolulu   false   AIX 4.3 unknown

Asia/Calcutta      true    Fedora Core release 3 GNU/Linux i686
Europe/London      true    Fedora Core releaes 3 GNU/Linux i686

Asia/Calcutta      true    FreeBSD 4.10-RELEASE-p2 i386
Europe/London      true    FreeBSD 4.10-RELEASE-p2 i386
Pacific/Honolulu   true    FreeBSD 4.10-RELEASE-p2 i386

Asia/Calcutta      true    FreeBSD 4.2-RELEASE i386
Europe/London      true    FreeBSD 4.2-RELEASE i386
Pacific/Honolulu   true    FreeBSD 4.2-RELEASE i386

Asia/Calcutta      true    FreeBSD 5.2-RELEASE i386
Europe/London      true    FreeBSD 5.2-RELEASE i386
Pacific/Honolulu   true    FreeBSD 5.2-RELEASE i386

Asia/Calcutta      true    Gentoo 1.4.16 GNU/Linux i686
Europe/London      true    Gentoo 1.4.16 GNU/Linux i686
Pacific/Honolulu   true    Gentoo 1.4.16 GNU/Linux i686

Asia/Calcutta      false   SunOS 5.8 SUNW,Sun-Blade-1000
Europe/London      false   SunOS 5.8 SUNW,Sun-Blade-1000
Pacific/Honolulu   false   SunOS 5.8 SUNW,Sun-Blade-1000

Asia/Calcutta      false   NetBSD 2.99.15 i386
Europe/London      false   NetBSD 2.99.15 i386
Pacific/Honolulu   false   NetBSD 2.99.15 i386

Asia/Calcutta      false   SunOS 5.7 SUNW,UltraSparc-IIi-cEngine
Europe/London      false   SunOS 5.7 SUNW,UltraSparc-IIi-cEngine
Pacific/Honolulu   false   SunOS 5.7 SUNW,UltraSparc-IIi-cEngine

Asia/Calcutta      true    SunOS 5.9 SUNW,Ultra-80
Europe/London      true    SunOS 5.9 SUNW,Ultra-80
Pacific/Honolulu   true    SunOS 5.9 SUNW,Ultra-80

Asia/Calcutta      false   UNICOS 9.0 CRAY Y-MP
Europe/London      false   UNICOS 9.0 CRAY Y-MP
Pacific/Honolulu   false   UNICOS 9.0 CRAY Y-MP

        Enjoy!
        -- Mark

 --------------- tz-test.sh ---------------
:
# 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
}

if valid_timezone ${1+"$@"}; then
  echo valid_timezone ${1+"$@"} = true
else
  echo valid_timezone ${1+"$@"} = false
fi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQFCYDp73x41pRYZE/gRAmk8AKDShDDwjjuZpanN7cfpVLJECqmcPACgxdvu
FJs7VStollRoIU/QR+2cgX8=
=CfdJ
-----END PGP SIGNATURE-----




reply via email to

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