#!/bin/sh5
########################################################################
#
#			Copyright (c) 1988, 1989 by
#		Digital Equipment Corporation, Maynard, MA
#			All rights reserved.
#
#	This software is furnished under a license and may be used and
#	copied  only  in accordance with the terms of such license and
#	with the  inclusion  of  the  above  copyright  notice.   This
#	software  or  any  other copies thereof may not be provided or
#	otherwise made available to any other person.  No title to and
#	ownership of the software is hereby transferred.		
#
#	The information in this software is subject to change  without
#	notice  and should not be construed as a commitment by Digital
#	Equipment Corporation.					
#
#	Digital assumes no responsibility for the use  or  reliability
#	of its software on equipment which is not supplied by Digital.
#
#	SCCSID = "@(#)tz_dst	4.1	(ULTRIX)	7/27/90"
#
#	000	Jonathan Wallace	1-Jun-1990
#
########################################################################
#
#
trap 'exit' 1 2 3 18
LL="
"
clear
while : true
do
	echo "
*** TIME ZONE SELECTION ***
	
Select the time zone for your area, using the options listed in the
table below.  You can also enter the number of hours (-12 to 12) in
time east of Greenwich.

  Selection	Time Zone 
---------------------------------
      e		Eastern
      c		Central
      m		Mountain
      p		Pacific
      g		Greenwich
---------------------------------

Enter your choice [no default]: \c"
	read zone
	case ${zone} in
	e|E)
		hourswest=5
		ZIC="/etc/zoneinfo/US/Eastern"
		;;
	c|C)
		hourswest=6
		ZIC="/etc/zoneinfo/US/Central"
		;;
	m|M)
		hourswest=7
		ZIC="/etc/zoneinfo/US/Mountain"
		;;
	p|P)
		hourswest=8
		ZIC="/etc/zoneinfo/US/Pacific"
		;;
	g|G)
		hourswest=0
		ZIC="/etc/zoneinfo/GMT"
		;;
	[0-9] | 1[0-2] )
		hourswest="-${zone}"
		ZIC="GMT${zone}"
		;;
	-[1-9] | -1[0-2] )
		hourswest=`expr $zone : '[-]\(.*\)'`
		ZIC="GMT${zone}"
		;;
	"")
		clear
		echo ""
		continue
		;;
	*)
		clear
	   	echo "
Sorry, {$zone}, is not a valid timezone option.  Please enter
one of the menu options listed below."
	   	continue
	   	;;
	esac
	break
done

while : true
do
	clear
	echo "
Does your area alternate between Daylight Savings and Standard
time? (y/n) [y]: \c"
	read dst
	case ${dst} in
	[yY]*|"")
		while true
		do
	   		echo "

Select your geographic area for Daylight Savings Time, using the
options in the table below.

  Selection	Geographic Area 
--------------------------------
      u		USA
      a		Australia
      e		Eastern Europe
      c		Central Europe
      w		Western Europe
--------------------------------

Enter your choice [no default]: \c"
			read dst
			case ${dst} in
			u|U) dst=1; geog=u ;;
			a|A) dst=2 ; geog=a;;
			w|W) dst=3; geog=w ;;
			c|C) dst=4; geog=c ;;
			e|E) dst=5; geog=e ;;
			*)
			     clear
			     echo "
Sorry, '${dst}' is not a valid option.  Please select a choice
from the menu below."
			     continue
			     ;;
			esac
			break
		done
		;;
	[nN]*)
		dst=n; geog=n
		;;
	*)
		echo ""
		continue
		;;
	esac
	break
done

case ${dst} in
"" | n) 
	TIMEZONE=$hourswest
	;;
*)  
	TIMEZONE="$hourswest dst ${dst}" 
	;;
esac

#
# Because the timezone in the kernel is in the east of USA,
# time needs to be adjusted.
# 
tt=`expr $hourswest : '-\(.*\)' '|' $hourswest`
tttt=`expr $tt '*' 60`
case $hourswest in
0 )  	tttt=0000	
	;;
1 ) 	tttt=00${tttt}	
	;;
-1 ) 	tttt=-00${tttt}
	;;
-* )	tttt=-0${tttt}	
	;;
* )	tttt=0${tttt}	
	;;
esac
# In case timezone and dst do not match 
tnc=`date +%y\%m\%d\%H\%M.%S`
date $tnc-$tttt$geog >/dev/null 2>&1 
/etc/zic -d /etc/zoneinfo -l $ZIC
echo "${LL}The current date and time is `date`"
echo "$TIMEZONE" > /tmp/timezone
sleep 3
exit 0
