* Fixed a multiselect bug in the mailbox view. Ctrl-click was selecting a message...
[citadel.git] / citadel / guesstimezone.sh
blob0c86ffce2bf7e549d53198094f032a58ca631047
1 #!/bin/sh
3 # guesstimezone.sh - an ugly hack of a script to try to guess the time
4 # zone currently in use on the host system, and output its name.
6 # Copyright (c) by Art Cancro
8 # This program is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by the Free
10 # Software Foundation; either version 3 of the License, or (at your option)
11 # any later version.
13 # This program is distributed in the hope that it will be useful, but WITHOUT
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 # more details.
18 # You should have received a copy of the GNU General Public License along
19 # with this program; if not, write to the Free Software Foundation, Inc.,
20 # 675 Mass Ave, Cambridge, MA 02139, USA.
22 convert_timezone()
24 case "$1" in
25 (right/*|posix/*)
26 convert_timezone "${1#*/}"
28 ("Africa/Asmera")
29 echo "Africa/Asmara"
31 ("America/Argentina/ComodRivadavia"|"America/Catamarca")
32 echo "America/Argentina/Catamarca"
34 ("America/Buenos_Aires")
35 echo "America/Argentina/Buenos_Aires"
37 ("America/Cordoba"|"America/Rosario")
38 echo "America/Argentina/Cordoba"
40 ("America/Jujuy")
41 echo "America/Argentina/Jujuy"
43 ("America/Mendoza")
44 echo "America/Argentina/Mendoza"
46 ("Antarctica/South_Pole")
47 echo "Antarctica/McMurdo"
49 "Asia/Ashkhabad")
50 echo "Asia/Ashgabat"
52 ("Asia/Calcutta")
53 echo "Asia/Kolkata"
55 "Asia/Chungking")
56 echo "Asia/Chongqing"
58 "Asia/Dacca")
59 echo "Asia/Dhaka"
61 ("Asia/Katmandu")
62 echo "Asia/Kathmandu"
64 "Asia/Macao")
65 echo "Asia/Macau"
67 ("Asia/Saigon")
68 echo "Asia/Ho_Chi_Minh"
70 "Asia/Thimbu")
71 echo "Asia/Thimphu"
73 "Asia/Ulan_Bator")
74 echo "Asia/Ulaanbaatar"
76 "Atlantic/Faeroe")
77 echo "Atlantic/Faroe"
79 "Australia/ACT" | "Australia/NSW")
80 echo "Australia/Sydney"
82 "Australia/LHI")
83 echo "Australia/Lord_Howe"
85 "Australia/North")
86 echo "Australia/Darwin"
88 "Australia/Queensland")
89 echo "Australia/Brisbane"
91 "Australia/South")
92 echo "Australia/Adelaide"
94 "Australia/Tasmania")
95 echo "Australia/Hobart"
97 "Australia/Victoria")
98 echo "Australia/Melbourne"
100 "Australia/West")
101 echo "Australia/Perth"
103 "Brazil/Acre")
104 echo "America/Rio_Branco"
106 "Brazil/DeNoronha")
107 echo "America/Noronha"
109 "Brazil/East")
110 echo "America/Sao_Paulo"
112 "Brazil/West")
113 echo "America/Manaus"
115 "Canada/Atlantic")
116 echo "America/Halifax"
118 "Canada/Central")
119 echo "America/Winnipeg"
121 "Canada/East-Saskatchewan")
122 echo "America/Regina"
124 "Canada/Eastern")
125 echo "America/Toronto"
127 "Canada/Mountain")
128 echo "America/Edmonton"
130 "Canada/Newfoundland")
131 echo "America/St_Johns"
133 "Canada/Pacific")
134 echo "America/Vancouver"
136 "Canada/Saskatchewan")
137 echo "America/Regina"
139 "Canada/Yukon")
140 echo "America/Whitehorse"
142 "CET")
143 echo "Europe/Paris"
145 "Chile/Continental")
146 echo "America/Santiago"
148 "Chile/EasterIsland")
149 echo "Pacific/Easter"
151 "CST6CDT")
152 echo "SystemV/CST6CDT"
154 "Cuba")
155 echo "America/Havana"
157 "EET")
158 echo "Europe/Helsinki"
160 "Egypt")
161 echo "Africa/Cairo"
163 "Eire")
164 echo "Europe/Dublin"
166 "EST")
167 echo "SystemV/EST5"
169 "EST5EDT")
170 echo "SystemV/EST5EDT"
172 "GB")
173 echo "Europe/London"
175 "GB-Eire")
176 echo "Europe/London"
178 "GMT")
179 echo "Etc/GMT"
181 "GMT0")
182 echo "Etc/GMT0"
184 "GMT-0")
185 echo "Etc/GMT-0"
187 "GMT+0")
188 echo "Etc/GMT+0"
190 "Greenwich")
191 echo "Etc/Greenwich"
193 "Hongkong")
194 echo "Asia/Hong_Kong"
196 "HST")
197 echo "Pacific/Honolulu"
199 "Iceland")
200 echo "Atlantic/Reykjavik"
202 "Iran")
203 echo "Asia/Tehran"
205 "Israel")
206 echo "Asia/Tel_Aviv"
208 "Jamaica")
209 echo "America/Jamaica"
211 "Japan")
212 echo "Asia/Tokyo"
214 "Kwajalein")
215 echo "Pacific/Kwajalein"
217 "Libya")
218 echo "Africa/Tripoli"
220 "MET")
221 echo "Europe/Paris"
223 "Mexico/BajaNorte")
224 echo "America/Tijuana"
226 "Mexico/BajaSur")
227 echo "America/Mazatlan"
229 "Mexico/General")
230 echo "America/Mexico_City"
232 "Mideast/Riyadh87")
233 echo "Asia/Riyadh87"
235 "Mideast/Riyadh88")
236 echo "Asia/Riyadh88"
238 "Mideast/Riyadh89")
239 echo "Asia/Riyadh89"
241 "MST")
242 echo "SystemV/MST7"
244 "MST7MDT")
245 echo "SystemV/MST7MDT"
247 "Navajo")
248 echo "America/Denver"
250 "NZ")
251 echo "Pacific/Auckland"
253 "NZ-CHAT")
254 echo "Pacific/Chatham"
256 "Poland")
257 echo "Europe/Warsaw"
259 "Portugal")
260 echo "Europe/Lisbon"
262 "PRC")
263 echo "Asia/Shanghai"
265 "PST8PDT")
266 echo "SystemV/PST8PDT"
268 "ROC")
269 echo "Asia/Taipei"
271 "ROK")
272 echo "Asia/Seoul"
274 "Singapore")
275 echo "Asia/Singapore"
277 "Turkey")
278 echo "Europe/Istanbul"
280 "UCT")
281 echo "Etc/UCT"
283 "Universal")
284 echo "Etc/UTC"
286 "US/Alaska")
287 echo "America/Anchorage"
289 "US/Aleutian")
290 echo "America/Adak"
292 "US/Arizona")
293 echo "America/Phoenix"
295 "US/Central")
296 echo "America/Chicago"
298 "US/East-Indiana")
299 echo "America/Indianapolis"
301 "US/Eastern")
302 echo "America/New_York"
304 "US/Hawaii")
305 echo "Pacific/Honolulu"
307 "US/Indiana-Starke")
308 echo "America/Indianapolis"
310 "US/Michigan")
311 echo "America/Detroit"
313 "US/Mountain")
314 echo "America/Denver"
316 "US/Pacific")
317 echo "America/Los_Angeles"
319 "US/Samoa")
320 echo "Pacific/Pago_Pago"
322 "UTC")
323 echo "Etc/UTC"
325 "WET")
326 echo "Europe/Lisbon"
328 "W-SU")
329 echo "Europe/Moscow"
331 "Zulu")
332 echo "Etc/UTC"
335 echo "$1"
337 esac
340 md5sum </dev/null >/dev/null 2>/dev/null || exit 1
342 # this check will find the timezone if /etc/localtime is a link to the right timezone file
343 # or that file has been copied to /etc/localtime and not changed afterwards
344 LOCALTIMESUM=`md5sum /etc/localtime | awk ' { print $1 } ' 2>/dev/null`
345 find /usr/share/zoneinfo -type f -print | while read filename
347 THISTIMESUM=`md5sum $filename | awk ' { print $1 } '`
348 if [ $LOCALTIMESUM = $THISTIMESUM ] ; then
349 echo $filename | cut -c21-
350 exit 0
352 done 2>/dev/null
354 # seems we haven't found the timezone yet, let's see whether /etc/timezone has some info
356 if [ -e /etc/timezone ]; then
357 TIMEZONE="$(head -n 1 /etc/timezone)"
358 TIMEZONE="${TIMEZONE%% *}"
359 TIMEZONE="${TIMEZONE##/}"
360 TIMEZONE="${TIMEZONE%%/}"
361 TIMEZONE="$(convert_timezone $TIMEZONE)"
362 if [ -f "/usr/share/zoneinfo/$TIMEZONE" ] ; then
363 echo $TIMEZONE
364 exit 0
368 exit 2