1238438Sdteskeif [ ! "$_TIMEZONE_ZONES_SUBR" ]; then _TIMEZONE_ZONES_SUBR=1
2238438Sdteske#
3238438Sdteske# Copyright (c) 2011-2012 Devin Teske
4252980Sdteske# All rights reserved.
5238438Sdteske#
6238438Sdteske# Redistribution and use in source and binary forms, with or without
7238438Sdteske# modification, are permitted provided that the following conditions
8238438Sdteske# are met:
9238438Sdteske# 1. Redistributions of source code must retain the above copyright
10238438Sdteske#    notice, this list of conditions and the following disclaimer.
11238438Sdteske# 2. Redistributions in binary form must reproduce the above copyright
12238438Sdteske#    notice, this list of conditions and the following disclaimer in the
13238438Sdteske#    documentation and/or other materials provided with the distribution.
14238438Sdteske#
15238438Sdteske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16252987Sdteske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17238438Sdteske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18238438Sdteske# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19238438Sdteske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20252987Sdteske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21238438Sdteske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22238438Sdteske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23238438Sdteske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24238438Sdteske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25238438Sdteske# SUCH DAMAGE.
26238438Sdteske#
27238438Sdteske# $FreeBSD$
28238438Sdteske#
29238438Sdteske############################################################ INCLUDES
30238438Sdteske
31240684SdteskeBSDCFG_SHARE="/usr/share/bsdconfig"
32240684Sdteske. $BSDCFG_SHARE/common.subr || exit 1
33244675Sdteskef_dprintf "%s: loading includes..." timezone/zones.subr
34240684Sdteskef_include $BSDCFG_SHARE/dialog.subr
35259054Sdteskef_include $BSDCFG_SHARE/strings.subr
36240684Sdteskef_include $BSDCFG_SHARE/timezone/continents.subr
37238438Sdteske
38240684SdteskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
39238438Sdteskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
40238438Sdteske
41238438Sdteske############################################################ CONFIGURATION
42238438Sdteske
43238438Sdteske#
44238438Sdteske# Standard pathnames
45238438Sdteske#
46238438Sdteske_PATH_ZONETAB="/usr/share/zoneinfo/zone.tab"
47238438Sdteske_PATH_ZONEINFO="/usr/share/zoneinfo"
48238438Sdteske_PATH_LOCALTIME="/etc/localtime"
49238438Sdteske_PATH_DB="/var/db/zoneinfo"
50238438Sdteske
51238438Sdteske#
52238438Sdteske# Export required i18n messages for awk(1) ENVIRON visibility
53238438Sdteske#
54238438Sdteskeexport msg_conflicting_zone_definition
55238438Sdteskeexport msg_country_code_invalid
56238438Sdteskeexport msg_country_code_unknown
57238438Sdteskeexport msg_invalid_country_code
58238438Sdteskeexport msg_invalid_format
59238438Sdteskeexport msg_invalid_region
60238438Sdteskeexport msg_invalid_zone_name
61238438Sdteskeexport msg_zone_multiply_defined
62238438Sdteskeexport msg_zone_must_have_description
63238438Sdteske
64238438Sdteske############################################################ FUNCTIONS
65238438Sdteske
66238438Sdteske# f_read_zones
67238438Sdteske#
68238438Sdteske# Read the zone descriptions database in _PATH_ZONETAB:
69238438Sdteske# 	/usr/share/zoneinfo/zone.tab on all OSes
70238438Sdteske#
71238438Sdteske# The format of this file (on all OSes) is:
72238438Sdteske# 	code	coordinates	TZ	comments
73238438Sdteske#
74238438Sdteske# With each of the following elements (described below) being separated by a
75238438Sdteske# single tab character:
76238438Sdteske#
77238438Sdteske# 	code
78238438Sdteske# 		The ISO 3166 2-character country code.
79238438Sdteske# 	coordinates
80238438Sdteske# 		Latitude and logitude of the zone's principal location in ISO
81238438Sdteske# 		6709 sign-degrees-minutes-seconds format, either +-DDMM+-DDDMM
82238438Sdteske# 		or +-DDMMSS+-DDDMMSS, first latitude (+ is north), then long-
83238438Sdteske# 		itude (+ is east).
84238438Sdteske# 	TZ
85238438Sdteske# 		Zone name used in value of TZ environment variable.
86238438Sdteske# 	comments
87238438Sdteske# 		Comments; present if and only if the country has multiple rows.
88238438Sdteske#
89238438Sdteske# Required variables [from continents.subr]:
90238438Sdteske#
91238438Sdteske# 	CONTINENTS
92238438Sdteske# 		Space-separated list of continents.
93238438Sdteske# 	continent_*_name
94238438Sdteske# 		Directory element in _PATH_ZONEINFO for the continent
95238438Sdteske# 		represented by *.
96238438Sdteske#
97238438Sdteske# Required variables [created by f_read_iso3166_table from iso3166.subr]:
98238438Sdteske#
99238438Sdteske# 	country_CODE_name
100238438Sdteske# 		Country name of the country represented by CODE, the 2-
101238438Sdteske# 		character country code.
102238438Sdteske#
103238438Sdteske# Variables created by this function:
104238438Sdteske#
105238438Sdteske# 	country_CODE_nzones
106238438Sdteske# 		Either set to `-1' to indicate that the 2-character country
107238438Sdteske# 		code has only a single zone associated with it (and therefore
108238438Sdteske# 		you should query the `country_CODE_*' environment variables),
109238438Sdteske# 		or set to `0' or higher to indicate how many zones are assoc-
110238438Sdteske# 		iated with the given country code. When multiple zones are
111238438Sdteske# 		configured for a single code, you should instead query the
112238438Sdteske# 		`country_CODE_*_N' environment variables (e.g., `echo
113238438Sdteske# 		$country_AQ_descr_1' prints the description of the first
114238438Sdteske# 		timezone in Antarctica).
115238438Sdteske# 	country_CODE_filename
116238438Sdteske# 		The ``filename'' portion of the TZ value that appears after the
117238438Sdteske# 		`/' (e.g., `Hong_Kong' from `Asia/Hong_Kong' or `Isle_of_Man'
118238438Sdteske# 		from `Europe/Isle_of_Man').
119238438Sdteske# 	country_CODE_cont
120238438Sdteske# 		The ``continent'' portion of the TZ value that appears before
121238438Sdteske# 		the `/' (e.g., `Asia' from `Asia/Hong_Kong' or `Europe' from
122238438Sdteske# 		`Europe/Isle_of_Man').
123238438Sdteske# 	country_CODE_descr
124238438Sdteske# 		The comments associated with the ISO 3166 code entry (if any).
125238438Sdteske#
126238438Sdteske# 	NOTE: CODE is the 2-character country code.
127238438Sdteske# 	
128238438Sdteske# This function is a two-parter. Below is the awk(1) portion of the function,
129238438Sdteske# afterward is the sh(1) function which utilizes the below awk script.
130238438Sdteske#
131238438Sdteskef_read_zones_awk='
132238438Sdteske# Variables that should be defined on the invocation line:
133238438Sdteske# 	-v progname="progname"
134238438Sdteske#
135238438SdteskeBEGIN {
136238438Sdteske	lineno = 0
137238438Sdteske	failed = 0
138238438Sdteske
139238438Sdteske	#
140238438Sdteske	# Initialize continents array/map (name => id)
141238438Sdteske	#
142238438Sdteske	split(ENVIRON["CONTINENTS"], array, /[[:space:]]+/)
143238438Sdteske	for (item in array)
144238438Sdteske	{
145238438Sdteske		cont = array[item]
146238438Sdteske		if (!cont) continue
147238438Sdteske		name = ENVIRON["continent_" cont "_name"]
148238438Sdteske		continents[name] = cont
149238438Sdteske	}
150238438Sdteske}
151238438Sdteskefunction die(fmt, argc, argv)
152238438Sdteske{
153238438Sdteske	printf "f_die 1 \"%%s: %s\" \"%s\"", fmt, progname
154238438Sdteske	for (n = 1; n <= argc; n++)
155238438Sdteske		printf " \"%s\"", argv[n]
156238438Sdteske	print ""
157238438Sdteske	failed++
158238438Sdteske	exit 1
159238438Sdteske}
160238438Sdteskefunction find_continent(name)
161238438Sdteske{
162238438Sdteske	return continents[name]
163238438Sdteske}
164238438Sdteskefunction add_zone_to_country(lineno, tlc, descr, file, cont)
165238438Sdteske{
166238438Sdteske	#
167238438Sdteske	# Validate the two-character country code
168238438Sdteske	#
169238438Sdteske	if (!match(tlc, /^[A-Z][A-Z]$/))
170238438Sdteske	{
171238438Sdteske		argv[1] = FILENAME
172238438Sdteske		argv[2] = lineno
173238438Sdteske		argv[3] = tlc
174238438Sdteske		die(ENVRION["msg_country_code_invalid"], 3, argv)
175238438Sdteske	}
176238438Sdteske	if (!ENVIRON["country_" tlc "_name"])
177238438Sdteske	{
178238438Sdteske		argv[1] = FILENAME
179238438Sdteske		argv[2] = lineno
180238438Sdteske		argv[3] = tlc
181238438Sdteske		die(ENVIRON["msg_country_code_unknown"], 3, argv)
182238438Sdteske	}
183238438Sdteske
184238438Sdteske	#
185238438Sdteske	# Add Zone to an array that we will parse at the end
186238438Sdteske	#
187238438Sdteske	if (length(descr) > 0)
188238438Sdteske	{
189238438Sdteske		if (country_nzones[tlc] < 0)
190238438Sdteske		{
191238438Sdteske			argv[1] = FILENAME
192238438Sdteske			argv[2] = lineno
193238438Sdteske			die(ENVIRON["msg_conflicting_zone_definition"], 2, argv)
194238438Sdteske		}
195238438Sdteske
196238438Sdteske		n = ++country_nzones[tlc]
197238438Sdteske		country_cont[tlc,n] = cont
198238438Sdteske		country_filename[tlc,n] = file
199238438Sdteske		country_descr[tlc,n] = descr
200238438Sdteske	}
201238438Sdteske	else
202238438Sdteske	{
203238438Sdteske		if (country_nzones[tlc] > 0)
204238438Sdteske		{
205238438Sdteske			argv[1] = FILENAME
206238438Sdteske			argv[2] = lineno
207238438Sdteske			die(ENVIRON["msg_zone_must_have_description"], 2, argv)
208238438Sdteske		}
209238438Sdteske		if (country_nzones[tlc] < 0)
210238438Sdteske		{
211238438Sdteske			argv[1] = FILENAME
212238438Sdteske			argv[2] = lineno
213238438Sdteske			die(ENVIRON["msg_zone_multiply_defined"], 2, argv)
214238438Sdteske		}
215238438Sdteske
216238438Sdteske		country_nzones[tlc] = -1
217238438Sdteske		country_cont[tlc] = cont
218238438Sdteske		country_filename[tlc] = file
219238438Sdteske	}
220238438Sdteske}
221238438Sdteskefunction print_country_code(tlc)
222238438Sdteske{
223238438Sdteske	nz = country_nzones[tlc]
224238438Sdteske
225238438Sdteske	printf "country_%s_nzones=%d\n", tlc, nz
226238438Sdteske	printf "export country_%s_nzones\n", tlc
227238438Sdteske
228238438Sdteske	if (nz < 0)
229238438Sdteske	{
230238438Sdteske		printf "country_%s_cont=\"%s\"\n", tlc, country_cont[tlc]
231238438Sdteske		printf "export country_%s_cont\n", tlc
232238438Sdteske		printf "country_%s_filename=\"%s\"\n",
233238438Sdteske		       tlc, country_filename[tlc]
234238438Sdteske	}
235238438Sdteske	else
236238438Sdteske	{
237238438Sdteske		n = 0
238238438Sdteske		while ( ++n <= nz )
239238438Sdteske		{
240238438Sdteske			printf "country_%s_cont_%d=\"%s\"\n",
241238438Sdteske			       tlc, n, country_cont[tlc,n]
242238438Sdteske			printf "export country_%s_cont_%d\n", tlc, n
243238438Sdteske			printf "country_%s_filename_%d=\"%s\"\n",
244238438Sdteske			       tlc, n, country_filename[tlc,n]
245238438Sdteske			printf "country_%s_descr_%d=\"%s\"\n",
246238438Sdteske			       tlc, n, country_descr[tlc,n]
247238438Sdteske		}
248238438Sdteske	}
249238438Sdteske}
250238438Sdteske/^#/ {
251238438Sdteske	lineno++
252238438Sdteske	next
253238438Sdteske}
254238438Sdteske!/^#/ {
255238438Sdteske	lineno++
256238438Sdteske
257238438Sdteske	#
258238438Sdteske	# Split the current record (on TAB) into an array
259238438Sdteske	#
260238438Sdteske	if (split($0, line, /\t/) < 2)
261238438Sdteske	{
262238438Sdteske		argv[1] = FILENAME
263238438Sdteske		argv[2] = lineno
264238438Sdteske		die(ENVIRON["msg_invalid_format"], 2, argv)
265238438Sdteske	}
266238438Sdteske
267238438Sdteske	# Get the ISO3166-1 (Alpha 1) 2-letter country code
268238438Sdteske	tlc = line[1]
269238438Sdteske
270238438Sdteske	#
271238438Sdteske	# Validate the two-character country code
272238438Sdteske	#
273238438Sdteske	if (length(tlc) != 2)
274238438Sdteske	{
275238438Sdteske		argv[1] = FILENAME
276238438Sdteske		argv[2] = lineno
277238438Sdteske		argv[3] = tlc
278238438Sdteske		die(ENVIRON["msg_invalid_country_code"], 3, argv)
279238438Sdteske	}
280238438Sdteske
281238438Sdteske	# Get the TZ field
282238438Sdteske	tz = line[3]
283238438Sdteske
284238438Sdteske	#
285238438Sdteske	# Validate the TZ field
286238438Sdteske	#
287238438Sdteske	if (!match(tz, "/"))
288238438Sdteske	{
289238438Sdteske		argv[1] = FILENAME
290238438Sdteske		argv[2] = lineno
291238438Sdteske		argv[3] = tz
292238438Sdteske		die(ENVIRON["msg_invalid_zone_name"], 3, argv)
293238438Sdteske	}
294238438Sdteske
295238438Sdteske	#
296238438Sdteske	# Get the continent portion of the TZ field
297238438Sdteske	#
298238438Sdteske	contbuf = tz
299238438Sdteske	sub("/.*$", "", contbuf)
300238438Sdteske
301238438Sdteske	#
302238438Sdteske	# Validate the continent
303238438Sdteske	#
304238438Sdteske	cont = find_continent(contbuf)
305238438Sdteske	if (!cont)
306238438Sdteske	{
307238438Sdteske		argv[1] = FILENAME
308238438Sdteske		argv[2] = lineno
309238438Sdteske		argv[3] = contbuf
310238438Sdteske		die(ENVIRON["msg_invalid_region"], 3, argv)
311238438Sdteske	}
312238438Sdteske
313238438Sdteske	#
314238438Sdteske	# Get the filename portion of the TZ field
315238438Sdteske	#
316238438Sdteske	filename = tz
317238438Sdteske	sub("^[^/]*/", "", filename)
318238438Sdteske
319238438Sdteske	#
320238438Sdteske	# Calculate the substr start-position of the comment
321238438Sdteske	#
322238438Sdteske	descr_start = 0
323238438Sdteske	n = 4
324238438Sdteske	while (--n)
325238438Sdteske		descr_start += length(line[n]) + 1
326238438Sdteske
327238438Sdteske	# Get the comment field
328238438Sdteske	descr = substr($0, descr_start + 1)
329238438Sdteske
330238438Sdteske	add_zone_to_country(lineno, tlc, descr, filename, cont)
331238438Sdteske}
332238438SdteskeEND {
333238438Sdteske	if (failed) exit failed
334238438Sdteske	for (tlc in country_nzones)
335238438Sdteske		print_country_code(tlc)
336238438Sdteske}
337238438Sdteske'
338238438Sdteskef_read_zones()
339238438Sdteske{
340238438Sdteske	eval $( awk -v progname="$pgm"   \
341238438Sdteske	            "$f_read_zones_awk"  \
342238438Sdteske	            "$_PATH_ZONETAB"     )
343238438Sdteske}
344238438Sdteske
345238438Sdteske# f_install_zoneinfo_file $filename
346238438Sdteske#
347238438Sdteske# Installs a zone file to _PATH_LOCALTIME.
348238438Sdteske#
349238438Sdteskef_install_zoneinfo_file()
350238438Sdteske{
351259054Sdteske	local funcname=f_install_zoneinfo_file
352238438Sdteske	local zoneinfo_file="$1"
353259054Sdteske	local copymode title msg height width
354238438Sdteske
355238438Sdteske	if [ -L "$_PATH_LOCALTIME" ]; then
356238438Sdteske		copymode=
357238438Sdteske	elif [ ! -e "$_PATH_LOCALTIME" ]; then
358238438Sdteske		# Nothing there yet...
359238438Sdteske		copymode=1
360238438Sdteske	else
361238438Sdteske		copymode=1
362238438Sdteske	fi
363238438Sdteske
364238438Sdteske	if [ "$VERBOSE" ]; then
365238438Sdteske		if [ ! "$zoneinfo_file" ]; then
366259054Sdteske			f_sprintf msg "$msg_removing_file" "$_PATH_LOCALTIME"
367238438Sdteske		elif [ "$copymode" ]; then
368259054Sdteske			f_sprintf msg "$msg_copying_file" \
369259054Sdteske			              "$zoneinfo_file" "$_PATH_LOCALTIME"
370238438Sdteske		else
371259054Sdteske			f_sprintf msg "$msg_creating_symlink" \
372259054Sdteske			              "$_PATH_LOCALTIME" "$zoneinfo_file"
373238438Sdteske		fi
374238438Sdteske		if [ "$USEDIALOG" ]; then
375238438Sdteske			f_dialog_title "$msg_info"
376251978Sdteske			f_dialog_msgbox "$msg"
377238438Sdteske			f_dialog_title_restore
378238438Sdteske		else
379238438Sdteske			printf "%s\n" "$msg"
380238438Sdteske		fi
381238438Sdteske	fi
382238438Sdteske
383251980Sdteske	[ "$REALLYDOIT" ] || return $SUCCESS
384251980Sdteske
385259054Sdteske	local catch_args="-de"
386259054Sdteske	[ "$USEDIALOG" ] && catch_args=
387259054Sdteske
388251980Sdteske	if [ ! "$zoneinfo_file" ]; then
389259054Sdteske		f_eval_catch $catch_args $funcname rm \
390259054Sdteske			'rm -f "%s"' "$_PATH_LOCALTIME" || return $FAILURE
391259054Sdteske		f_eval_catch $catch_args $funcname rm \
392259054Sdteske			'rm -f "%s"' "$_PATH_DB" || return $FAILURE
393238438Sdteske
394251980Sdteske		if [ "$VERBOSE" ]; then
395259054Sdteske			f_sprintf msg "$msg_removed_file" "$_PATH_LOCALTIME"
396251980Sdteske			if [ "$USEDIALOG" ]; then
397251980Sdteske				f_dialog_title "$msg_done"
398251980Sdteske				f_dialog_msgbox "$msg"
399251980Sdteske				f_dialog_title_restore
400251980Sdteske			else
401251980Sdteske				printf "%s\n" "$msg"
402238438Sdteske			fi
403251980Sdteske		fi
404251980Sdteske		return $SUCCESS
405251980Sdteske	fi # ! zoneinfo_file
406238438Sdteske
407251980Sdteske	if [ "$copymode" ]; then
408259054Sdteske		f_eval_catch $catch_args $funcname rm \
409259054Sdteske			'rm -f "%s"' "$_PATH_LOCALTIME" || return $FAILURE
410259054Sdteske		f_eval_catch $catch_args $funcname sh \
411259054Sdteske			'umask 222 && :> "%s"' "$_PATH_LOCALTIME" ||
412251980Sdteske			return $FAILURE
413259054Sdteske		f_eval_catch $catch_args $funcname sh \
414259054Sdteske			'cat "%s" > "%s"' \
415259054Sdteske			"$zoneinfo_file" "$_PATH_LOCALTIME" || return $FAILURE
416259054Sdteske	else
417259054Sdteske		f_eval_catch $catch_args $funcname sh \
418259054Sdteske			'( :< "%s" )' "$zoneinfo_file" || return $FAILURE
419259054Sdteske		f_eval_catch $catch_args $funcname rm \
420259054Sdteske			'rm -f "%s"' "$_PATH_LOCALTIME" || return $FAILURE
421259054Sdteske		f_eval_catch $catch_args $funcname ln \
422259054Sdteske			'ln -s "%s" "%s"' \
423259054Sdteske			"$zoneinfo_file" "$_PATH_LOCALTIME" || return $FAILURE
424251980Sdteske	fi # copymode
425238438Sdteske
426251980Sdteske	if [ "$VERBOSE" ]; then
427251980Sdteske		if [ "$copymode" ]; then
428259054Sdteske			f_sprintf msg "$msg_copied_timezone_file" \
429259054Sdteske			              "$zoneinfo_file" "$_PATH_LOCALTIME"
430251980Sdteske		else
431259054Sdteske			f_sprintf msg "$msg_created_symlink" \
432259054Sdteske			              "$_PATH_LOCALTIME" "$zoneinfo_file"
433251980Sdteske		fi
434251980Sdteske		if [ "$USEDIALOG" ]; then
435251980Sdteske			f_dialog_title "$msg_done"
436251980Sdteske			f_dialog_msgbox "$msg"
437251980Sdteske			f_dialog_title_restore
438251980Sdteske		else
439251980Sdteske			printf "%s\n" "$msg"
440251980Sdteske		fi
441251980Sdteske	fi
442251980Sdteske
443238438Sdteske	return $SUCCESS
444238438Sdteske}
445238438Sdteske
446238438Sdteske# f_install_zoneinfo $zoneinfo
447238438Sdteske#
448238438Sdteske# Install a zoneinfo file relative to _PATH_ZONEINFO. The given $zoneinfo
449238438Sdteske# will be written to _PATH_DB (usable later with the `-r' flag).
450238438Sdteske#
451238438Sdteskef_install_zoneinfo()
452238438Sdteske{
453238438Sdteske	local zoneinfo="$1"
454238438Sdteske	local rv
455238438Sdteske
456238438Sdteske	f_install_zoneinfo_file "$_PATH_ZONEINFO/$zoneinfo"
457238438Sdteske	rv=$?
458238438Sdteske
459238438Sdteske	# Save knowledge for later
460238438Sdteske	if [ "$REALLYDOIT" -a $rv -eq $SUCCESS ]; then
461240843Sdteske		if true 2> /dev/null > "$_PATH_DB"; then
462238438Sdteske			cat <<-EOF > "$_PATH_DB"
463238438Sdteske			$zoneinfo
464238438Sdteske			EOF
465238438Sdteske		fi
466238438Sdteske	fi
467238438Sdteske
468238438Sdteske	return $rv
469238438Sdteske}
470243476Sdteske
471238438Sdteske# f_confirm_zone $filename
472238438Sdteske#
473238438Sdteske# Prompt the user to confirm the new timezone data. The first (and only)
474238438Sdteske# argument should be the pathname to the zoneinfo file, either absolute or
475238438Sdteske# relative to `/usr/share/zoneinfo' (e.g., "America/Los_Angeles").
476238438Sdteske#
477238438Sdteske# The return status is 0 if "Yes" is chosen, 1 if "No", and 255 if Esc is
478238438Sdteske# pressed (see dialog(1) for additional details).
479238438Sdteske# 
480238438Sdteskef_confirm_zone()
481238438Sdteske{
482238438Sdteske	local filename="$1"
483238438Sdteske	f_dialog_title "$msg_confirmation"
484238438Sdteske	local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
485238438Sdteske	f_dialog_title_restore
486238438Sdteske	local tm_zone="$( TZ="$filename" date +%Z )"
487259054Sdteske	local prompt # Calculated below
488238438Sdteske	local height=5 width=72
489238438Sdteske
490259054Sdteske	f_sprintf prompt "$msg_look_reasonable" "$tm_zone"
491238438Sdteske	if [ "$USE_XDIALOG" ]; then
492238438Sdteske		height=$(( $height + 4 ))
493238438Sdteske		$DIALOG \
494259054Sdteske			--title "$title"         \
495259054Sdteske			--backtitle "$btitle"    \
496259054Sdteske			--ok-label "$msg_yes"    \
497259054Sdteske			--cancel-label "$msg_no" \
498238438Sdteske			--yesno "$prompt" $height $width
499238438Sdteske	else
500238438Sdteske		$DIALOG \
501238438Sdteske			--title "$title"       \
502238438Sdteske			--backtitle "$btitle"  \
503238438Sdteske			--yes-label "$msg_yes" \
504238438Sdteske			--no-label "$msg_no"   \
505238438Sdteske			--yesno "$prompt" $height $width
506238438Sdteske	fi
507238438Sdteske}
508238438Sdteske
509238438Sdteske# f_set_zone_utc
510238438Sdteske#
511238438Sdteske# Resets to the UTC timezone.
512238438Sdteske#
513238438Sdteskef_set_zone_utc()
514238438Sdteske{
515238438Sdteske	f_confirm_zone "" || return $FAILURE
516238438Sdteske	f_install_zoneinfo_file ""
517238438Sdteske}
518238438Sdteske
519244675Sdteske############################################################ MAIN
520244675Sdteske
521244675Sdteskef_dprintf "%s: Successfully loaded." timezone/zones.subr
522244675Sdteske
523238438Sdteskefi # ! $_TIMEZONE_ZONES_SUBR
524