All pastes #629541 Raw Edit

Etwas

public text v1 · immutable
·published 2007-07-22 12:03 UTC
rendered paste body
Index: packages/utils/timezone/files/usr/lib/timezones.csv
===================================================================
--- packages/utils/timezone/files/usr/lib/timezones.csv	(revision 0)
+++ packages/utils/timezone/files/usr/lib/timezones.csv	(revision 0)
@@ -0,0 +1,114 @@
+#timezone group	timezone cities	timezone config string	zoneinfo
+#revision: 2007f
+#  it is not exact for the "cities list" but it enables to remember 
+#  the selection and to synchronize TZs with the standard zoneinfo
+Australia	Melbourne,Canberra,Sydney	EST-10EST,M10.5.0,M3.5.0/3	Australia/Melbourne
+Australia	Perth	WST-8	Australia/Perth	Perth
+Australia	Brisbane	EST-10	Australia/Brisbane
+Australia	Adelaide	CST-9:30CST,M10.5.0,M3.5.0/3	Australia/Adelaide
+Australia	Darwin	CST-9:30	Australia/Darwin
+Australia	Hobart	EST-10EST,M10.1.0,M3.5.0/3	Australia/Hobart
+
+Europe	Amsterdam,Netherlands	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Amsterdam
+Europe	Athens,Greece	EET-2EEST,M3.5.0/3,M10.5.0/4	Europe/Athens
+Europe	Berlin,Germany	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Berlin
+Europe	Brussels,Belgium	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Brussels
+Europe	Bratislava,Slovakia	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Bratislava
+Europe	Budapest,Hungary	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Budapest
+Europe	Copenhagen,Denmark	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Copenhagen
+Europe	Dublin,Ireland	GMT0IST,M3.5.0/1,M10.5.0	Europe/Dublin
+Europe	Helsinki,Finland	EET-2EEST,M3.5.0/3,M10.5.0/4	Europe/Helsinki
+Europe	Kyiv,Ukraine	EET-2EEST,M3.5.0/3,M10.5.0/4	Europe/Kiev
+Europe	Lisbon,Portugal	WET0WEST,M3.5.0/1,M10.5.0	Europe/Lisbon
+Europe	London,GreatBritain	GMT0BST,M3.5.0/1,M10.5.0	Europe/London
+Europe	Madrid,Spain	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Madrid
+Europe	Oslo,Norway	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Oslo
+Europe	Paris,France	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Paris
+Europe	Prague,CzechRepublic	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Prague
+Europe	Roma,Italy	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Rome
+Europe	Moscow,Russia	MSK-3MSD,M3.5.0,M10.5.0/3	Europe/Moscow
+Europe	Stockholm,Sweden	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Stockholm
+Europe	Zurich,Switzerland	CET-1CEST,M3.5.0,M10.5.0/3	Europe/Zurich
+
+New Zealand	Auckland, Wellington	NZST-12NZDT,M10.1.0,M3.3.0/3	Pacific/Auckland
+
+USA & Canada	Hawaii Time	HST10	Pacific/Honolulu
+USA & Canada	Alaska Time	AKST9AKDT,M3.2.0,M11.1.0	America/Anchorage
+USA & Canada	Pacific Time	PST8PDT,M3.2.0,M11.1.0	America/Los_Angeles
+USA & Canada	Mountain Time	MST7MDT,M3.2.0,M11.1.0	America/Denver
+USA & Canada	Mountain Time (Arizona, no DST)	MST7	America/Phoenix
+USA & Canada	Central Time	CST6CDT,M3.2.0,M11.1.0	America/Chicago
+USA & Canada	Eastern Time	EST5EDT,M3.2.0,M11.1.0	America/New_York
+
+Atlantic	Bermuda	AST4ADT,M3.2.0,M11.1.0	Atlantic/Bermuda
+
+Asia (UTC+1)	Anadyr	ANAT-12ANAST,M3.5.0,M10.5.0/3	Asia/Anadyr
+
+Asia (UTC+2)	Amman	EET-2EEST,M3.5.4/0,M10.5.5/1	Asia/Amman
+Asia (UTC+2)	Beirut	EET-2EEST,M3.5.0/0,M10.5.0/0	Asia/Beirut
+Asia (UTC+2)	Damascus	EET-2EEST,J91/0,J274/0	Asia/Damascus
+Asia (UTC+2)	Gaza	EET-2EEST,J91/0,M10.3.5/0	Asia/Gaza
+Asia (UTC+2)	Jerusalem	GMT-2	Asia/Jerusalem
+Asia (UTC+2)	Nicosia	EET-2EEST,M3.5.0/3,M10.5.0/4	Asia/Nicosia
+
+Asia (UTC+3)	Aden	AST-3	Asia/Aden
+Asia (UTC+3)	Baghdad	AST-3ADT,J91/3,J274/4	Asia/Baghdad
+Asia (UTC+3)	Bahrain	AST-3	Asia/Bahrain
+Asia (UTC+3)	Kuwait	AST-3	Asia/Kuwait
+Asia (UTC+3)	Qatar	AST-3	Asia/Qatar
+Asia (UTC+3)	Riyadh	AST-3	Asia/Riyadh
+
+Asia (UTC+3:30)	Tehran	IRST-3:30	Asia/Tehran
+
+Asia (UTC+4)	Baku	AZT-4AZST,M3.5.0/4,M10.5.0/5	Asia/Baku
+Asia (UTC+4)	Dubai	GST-4	Asia/Dubai
+Asia (UTC+4)	Muscat	GST-4	Asia/Muscat
+Asia (UTC+4)	Tbilisi	GET-4	Asia/Tbilisi
+Asia (UTC+4)	Yerevan	AMT-4AMST,M3.5.0,M10.5.0/3	Asia/Yerevan
+
+Asia (UTC+4:30)	Kabul	AFT-4:30	Asia/Kabul
+
+Asia (UTC+5)	Aqtobe	AQTT-5	Asia/Aqtobe
+Asia (UTC+5)	Ashgabat	TMT-5	Asia/Ashgabat
+Asia (UTC+5)	Dushanbe	TJT-5	Asia/Dushanbe
+Asia (UTC+5)	Karachi	PKT-5	Asia/Karachi
+Asia (UTC+5)	Oral	ORAT-5	Asia/Oral
+Asia (UTC+5)	Samarkand	UZT-5	Asia/Samarkand
+Asia (UTC+5)	Tashkent	UZT-5	Asia/Tashkent
+Asia (UTC+5)	Yekaterinburg	YEKT-5YEKST,M3.5.0,M10.5.0/3	Asia/Yekaterinburg
+
+Asia (UTC+5:30)	Calcutta	IST-5:30	Asia/Calcutta
+Asia (UTC+5:30)	Colombo	IST-5:30	Asia/Colombo
+
+Asia (UTC+6)	Almaty	ALMT-6	Asia/Almaty
+Asia (UTC+6)	Bishkek	KGT-6	Asia/Bishkek
+Asia (UTC+6)	Dhaka	BDT-6	Asia/Dhaka
+Asia (UTC+6)	Novosibirsk	NOVT-6NOVST,M3.5.0,M10.5.0/3	Asia/Novosibirsk
+Asia (UTC+6)	Omsk	OMST-6OMSST,M3.5.0,M10.5.0/3	Asia/Omsk
+Asia (UTC+6)	Qyzylorda	QYZT-6	Asia/Qyzylorda
+Asia (UTC+6)	Thimphu	BTT-6	Asia/Thimphu
+
+Asia (UTC+7)	Jakarta	WIT-7	Asia/Jakarta
+Asia (UTC+7)	Bangkok	ICT-7	Asia/Bangkok
+Asia (UTC+7)	Vientiane	ICT-7	Asia/Vientiane
+Asia (UTC+7)	Phnom Penh	ICT-7	Asia/Phnom_Penh
+
+Asia (UTC+8)	Chongqing	CST-8	Asia/Chongqing
+Asia (UTC+8)	Hong Kong	HKT-8	Asia/Hong_Kong
+Asia (UTC+8)	Shanghai	CST-8	Asia/Shanghai
+Asia (UTC+8)	Singapore	SGT-8	Asia/Singapore
+Asia (UTC+8)	Urumqi	CST-8	Asia/Urumqi
+Asia (UTC+8)	Taiwan	CST-8	Asia/Taipei
+Asia (UTC+8)	Ulaanbaatar	ULAT-8	Asia/Ulaanbaatar
+
+Asia (UTC+9)	Dili	TLT-9	Asia/Dili
+Asia (UTC+9)	Jayapura	EIT-9	Asia/Jayapura
+Asia (UTC+9)	Pyongyang	KST-9	Asia/Pyongyang
+Asia (UTC+9)	Seoul	KST-9	Asia/Seoul
+Asia (UTC+9)	Tokyo	JST-9	Asia/Tokyo
+Asia (UTC+9)	Yakutsk	YAKT-9YAKST,M3.5.0,M10.5.0/3	Asia/Yakutsk
+
+Central and South America	Sao Paulo,Brazil	BRT3BRST,M11.1.0/0,M2.5.0/0	America/Sao_Paulo
+Central and South America	Argentina	ART3	America/Argentina/Buenos_Aires
+# no offense, just something in the center
+Central and South America	Central America (no DST)	CST6	America/Guatemala
Index: packages/utils/timezone/files/etc/config/timezone
===================================================================
--- packages/utils/timezone/files/etc/config/timezone	(revision 0)
+++ packages/utils/timezone/files/etc/config/timezone	(revision 0)
@@ -0,0 +1,4 @@
+config timezone
+	option posixtz  ''
+	option zoneinfo ''
+	option etctz    '/etc/TZ'
Index: packages/utils/timezone/files/etc/init.d/timezone
===================================================================
--- packages/utils/timezone/files/etc/init.d/timezone	(revision 0)
+++ packages/utils/timezone/files/etc/init.d/timezone	(revision 0)
@@ -0,0 +1,56 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+START=11
+
+EXTRA_COMMANDS="list"
+EXTRA_HELP="        list    Lists available time zones"
+
+TIMEZONE_TABLE=/usr/lib/timezones.csv
+
+get_posix_timezone () {
+	awk -v timezoneinfo="$zoneinfo" 'BEGIN { FS = "	" }
+		/^(#.*)?$/ { next }
+		{ list_timezone = $4; if ( list_timezone == timezoneinfo ) { print $3 } }
+		END { }' < $TIMEZONE_TABLE 2>/dev/null
+}
+
+list_available_timezones () {
+	awk 'BEGIN { FS = "	"; last_group="" }
+		/^(#.*)?$/ { next }
+		$1 != last_group { last_group=$1; print "\n" $1 }
+		{ list_timezone = $4; print "  " list_timezone }
+		END { }' < $TIMEZONE_TABLE 2>/dev/null
+}
+
+start_service () {
+	local section="$1"
+	config_get posixtz  "$section" posixtz
+	config_get zoneinfo "$section" zoneinfo
+	config_get etctz    "$section" etctz
+
+	if [ ! -h "$etctz" ]; then 
+		ln -sf /tmp/TZ "$etctz"
+	fi
+	[ -n "$zoneinfo" ] && get_posix_timezone "$zoneinfo" > "$etctz" || echo "UTC+0" > "$etctz"
+
+	# config_set
+	# posixtz=get_posix_timezone "$zoneinfo"
+
+	config_set "timezone" "posixtz" "foobar"
+}
+
+start () {
+	config_load "timezone"
+	config_foreach start_service timezone
+}
+
+restart () {
+	start
+}
+
+list () {
+	echo "Available time zones"
+	echo "--------------------"
+
+	list_available_timezones
+}
Index: packages/utils/timezone/Makefile
===================================================================
--- packages/utils/timezone/Makefile	(revision 0)
+++ packages/utils/timezone/Makefile	(revision 0)
@@ -0,0 +1,43 @@
+# 
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id$
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=timezone
+PKG_VERSION:=1.0
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/timezone
+  SECTION:=utils
+  CATEGORY:=Base system
+  TITLE:=Configure the time zone
+endef
+
+define Build/Prepare
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/timezone/install
+	$(INSTALL_DIR) $(1)/etc/config
+	$(INSTALL_CONF) ./files/etc/config/timezone $(1)/etc/config
+	$(INSTALL_DIR) $(1)/etc/init.d
+	$(INSTALL_BIN) ./files/etc/init.d/timezone $(1)/etc/init.d
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(INSTALL_DATA) ./files/usr/lib/timezones.csv $(1)/usr/lib
+endef
+
+$(eval $(call BuildPackage,timezone))