#!/bin/bash # $Header: /home/cvsd/magellan-cvs/magellan-src/installer/include/timezone.sh,v 1.1 2008-09-24 10:54:00 niro Exp $ checklist() { local i local item="$1" for i in ${LOCALE_LIST} do [[ ${i} = ${item} ]] && return 1 done return 0 } while read code coordinates tz comments do # excludes case ${code} in \#*|'') continue ;; esac region="${tz%%/*}" location="${tz#*/}" if [[ $1 = --regions ]] then if checklist "${region}" then LOCALE_LIST="${LOCALE_LIST} ${region}" fi elif [[ $1 = --locations ]] then [[ ${region} != $2 ]] && continue if checklist "${location}" then LOCALE_LIST="${LOCALE_LIST} ${location}" fi elif [[ $1 = --get-code ]] then [[ ${location} != $2 ]] && continue # location is the same, so print the code echo "${code}" elif [[ -z $1 ]] then echo "${tz}|${comments}" fi done << EOF $(cat /usr/share/zoneinfo/zone.tab | sort) EOF if [[ $1 = --regions ]] || [[ $1 = --locations ]] then for i in ${LOCALE_LIST} do echo "${i}" done | sort fi