From 00465c9a4b51b962e327bbbcc29fdf362397b2ac Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 6 Nov 2008 23:10:43 +0000 Subject: [PATCH] * luci-0.8: merge r3731-r3735 --- build/zoneinfo2lua.pl | 68 +++ libs/cbi/luasrc/cbi.lua | 228 ++++++++-- libs/sys/luasrc/sys/zoneinfo.lua | 408 ++++++++++++++++++ .../root/lib/uci/schema/default/system | 5 + .../luasrc/model/cbi/admin_system/system.lua | 30 +- .../luasrc/model/cbi/mini/system.lua | 34 +- 6 files changed, 711 insertions(+), 62 deletions(-) create mode 100644 build/zoneinfo2lua.pl create mode 100644 libs/sys/luasrc/sys/zoneinfo.lua diff --git a/build/zoneinfo2lua.pl b/build/zoneinfo2lua.pl new file mode 100644 index 000000000..fdcc3d60e --- /dev/null +++ b/build/zoneinfo2lua.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl +# zoneinfo2lua.pl - Make Lua module from /usr/share/zoneinfo +# Execute from within /usr/share/zoneinfo +# $Id$ + +use strict; + +my %TZ; + +local $/ = "\012"; +open( ZTAB, "< ./zone.tab" ) || die "Unable to open zone.tab: $!"; + +while( ! eof ZTAB ) { + chomp( my $line = readline ZTAB ); + next if $line =~ /^#/ || $line =~ /^\s+$/; + + my ( undef, undef, $zone, @comment ) = split /\s+/, $line; + + printf STDERR "%-40s", $zone; + + if( open ZONE, "< ./$zone" ) { + seek ZONE, -2, 2; + + while( tell(ZONE) > 0 ) { + read ZONE, my $char, 1; + ( $char eq "\012" ) ? last : seek ZONE, -2, 1; + } + + chomp( my $tz = readline ZONE ); + print STDERR ( $tz || "(no tzinfo found)" ), "\n"; + close ZONE; + + if( $tz ) { + $zone =~ s/_/ /g; + $TZ{$zone} = $tz; + } + } + else + { + print STDERR "Unable to open $zone: $!\n"; + } +} + +close ZTAB; + + +print < 0 then + for i, child in ipairs(self.children) do + if state == child then + return self.children[i+1] + end + end + else + return state + end +end + +function Delegator.parse(self, ...) + local active = self:getactive() + assert(active, "Invalid state") + + local cstate = active.node:parse() + self.active = active.transistor(self, active.node, cstate) + + if not self.active then + return FORM_DONE + else + self.active:parse(false) + return FROM_PROCEED + end +end + +function Delegator.render(self, ...) + self.active.node:render(...) +end + +function Delegator.getactive(self) + return self:get(Map.formvalue(self, "cbi.delegated") + or (self.children[1] and self.children[1].name)) +end --[[ Page - A simple node @@ -436,10 +549,16 @@ function SimpleForm.__init__(self, config, title, description, data) self.data = data or {} self.template = "cbi/simpleform" self.dorender = true + self.pageaction = false + self.readinput = true end -function SimpleForm.parse(self, ...) - if luci.http.formvalue("cbi.submit") then +SimpleForm.formvalue = Map.formvalue +SimpleForm.formvaluetable = Map.formvaluetable + +function SimpleForm.parse(self, readinput, ...) + self.readinput = (readinput ~= false) + if self:submitstate() then Node.parse(self, 1, ...) end @@ -449,6 +568,7 @@ function SimpleForm.parse(self, ...) valid = valid and (not v.tag_missing or not v.tag_missing[1]) and (not v.tag_invalid or not v.tag_invalid[1]) + and (not v.error) end end @@ -468,7 +588,7 @@ function SimpleForm.render(self, ...) end function SimpleForm.submitstate(self) - return luci.http.formvalue("cbi.submit") + return self:formvalue("cbi.submit") end function SimpleForm.section(self, class, ...) @@ -541,6 +661,7 @@ function AbstractSection.__init__(self, map, sectiontype, ...) self.tag_error = {} self.tag_invalid = {} self.tag_deperror = {} + self.changed = false self.optional = true self.addremove = false @@ -586,7 +707,7 @@ function AbstractSection.parse_optionals(self, section) self.optionals[section] = {} - local field = luci.http.formvalue("cbi.opt."..self.config.."."..section) + local field = self.map:formvalue("cbi.opt."..self.config.."."..section) for k,v in ipairs(self.children) do if v.optional and not v:cfgvalue(section) then if field == v.option then @@ -615,7 +736,7 @@ function AbstractSection.parse_dynamic(self, section) end local arr = luci.util.clone(self:cfgvalue(section)) - local form = luci.http.formvaluetable("cbid."..self.config.."."..section) + local form = self.map:formvaluetable("cbid."..self.config.."."..section) for k, v in pairs(form) do arr[k] = v end @@ -640,6 +761,12 @@ function AbstractSection.cfgvalue(self, section) return self.map:get(section) end +-- Push events +function AbstractSection.push_events(self) + --luci.util.append(self.map.events, self.events) + self.map.changed = true +end + -- Removes the section function AbstractSection.remove(self, section) return self.map:del(section) @@ -686,13 +813,17 @@ function Table.__init__(self, form, data, ...) local datasource = {} datasource.config = "table" self.data = data + + datasource.formvalue = Map.formvalue + datasource.formvaluetable = Map.formvaluetable + datasource.readinput = true function datasource.get(self, section, option) return data[section] and data[section][option] end function datasource.submitstate(self) - return luci.http.formvalue("cbi.submit") + return Map.formvalue(self, "cbi.submit") end function datasource.del(...) @@ -709,7 +840,8 @@ function Table.__init__(self, form, data, ...) self.anonymous = true end -function Table.parse(self) +function Table.parse(self, readinput) + self.map.readinput = (readinput ~= false) for i, k in ipairs(self:cfgsections()) do if self.map:submitstate() then Node.parse(self, k) @@ -761,11 +893,12 @@ function NamedSection.parse(self, novld) if self.addremove then local path = self.config.."."..s if active then -- Remove the section - if luci.http.formvalue("cbi.rns."..path) and self:remove(s) then + if self.map:formvalue("cbi.rns."..path) and self:remove(s) then + self:push_events() return end else -- Create and apply default values - if luci.http.formvalue("cbi.cns."..path) then + if self.map:formvalue("cbi.cns."..path) then self:create(s) return end @@ -782,6 +915,10 @@ function NamedSection.parse(self, novld) end end AbstractSection.parse_optionals(self, s) + + if self.changed then + self:push_events() + end end end @@ -835,7 +972,7 @@ function TypedSection.parse(self, novld) if self.addremove then -- Remove local crval = REMOVE_PREFIX .. self.config - local name = luci.http.formvaluetable(crval) + local name = self.map:formvaluetable(crval) for k,v in pairs(name) do if k:sub(-2) == ".x" then k = k:sub(1, #k - 2) @@ -850,7 +987,7 @@ function TypedSection.parse(self, novld) for i, k in ipairs(self:cfgsections()) do AbstractSection.parse_dynamic(self, k) if self.map:submitstate() then - Node.parse(self, k) + Node.parse(self, k, novld) if not novld and not self.override_scheme and self.map.scheme then _uvl_validate_section(self, k) @@ -863,7 +1000,7 @@ function TypedSection.parse(self, novld) -- Create local created local crval = CREATE_PREFIX .. self.config .. "." .. self.sectiontype - local name = luci.http.formvalue(crval) + local name = self.map:formvalue(crval) if self.anonymous then if name then created = self:create() @@ -894,6 +1031,10 @@ function TypedSection.parse(self, novld) AbstractSection.parse_optionals(self, created) end end + + if created or self.changed then + self:push_events() + end end -- Verifies scope of sections @@ -1011,12 +1152,12 @@ end -- Return whether this object should be created function AbstractValue.formcreated(self, section) local key = "cbi.opt."..self.config.."."..section - return (luci.http.formvalue(key) == self.option) + return (self.map:formvalue(key) == self.option) end -- Returns the formvalue for this object function AbstractValue.formvalue(self, section) - return luci.http.formvalue(self:cbid(section)) + return self.map:formvalue(self:cbid(section)) end function AbstractValue.additional(self, value) @@ -1027,23 +1168,42 @@ function AbstractValue.mandatory(self, value) self.rmempty = not value end -function AbstractValue.parse(self, section) +function AbstractValue.parse(self, section, novld) local fvalue = self:formvalue(section) local cvalue = self:cfgvalue(section) if fvalue and #fvalue > 0 then -- If we have a form value, write it to UCI fvalue = self:transform(self:validate(fvalue, section)) - if not fvalue then - self.tag_invalid[section] = true + if not fvalue and not novld then + if self.error then + self.error[section] = "invalid" + else + self.error = { [section] = "invalid" } + end + self.map.save = false end if fvalue and not (fvalue == cvalue) then - self:write(section, fvalue) + if self:write(section, fvalue) then + -- Push events + self.section.changed = true + --luci.util.append(self.map.events, self.events) + end end else -- Unset the UCI or error if self.rmempty or self.optional then - self:remove(section) - elseif self.track_missing and (not fvalue or fvalue ~= cvalue) then - self.tag_missing[section] = true + if self:remove(section) then + -- Push events + self.section.changed = true + --luci.util.append(self.map.events, self.events) + end + elseif cvalue ~= fvalue and not novld then + self:write(section, fvalue or "") + if self.error then + self.error[section] = "missing" + else + self.error = { [section] = "missing" } + end + self.map.save = false end end end @@ -1372,8 +1532,8 @@ function DynamicList.formvalue(self, section) local valid = {} for i, v in ipairs(value) do if v and #v > 0 - and not luci.http.formvalue("cbi.rle."..section.."."..self.option.."."..i) - and not luci.http.formvalue("cbi.rle."..section.."."..self.option.."."..i..".x") then + and not self.map:formvalue("cbi.rle."..section.."."..self.option.."."..i) + and not self.map:formvalue("cbi.rle."..section.."."..self.option.."."..i..".x") then table.insert(valid, v) end end @@ -1420,8 +1580,8 @@ end function FileUpload.formcreated(self, section) return AbstractValue.formcreated(self, section) or - luci.http.formvalue("cbi.rlf."..section.."."..self.option) or - luci.http.formvalue("cbi.rlf."..section.."."..self.option..".x") + self.map:formvalue("cbi.rlf."..section.."."..self.option) or + self.map:formvalue("cbi.rlf."..section.."."..self.option..".x") end function FileUpload.cfgvalue(self, section) @@ -1435,8 +1595,8 @@ end function FileUpload.formvalue(self, section) local val = AbstractValue.formvalue(self, section) if val then - if not luci.http.formvalue("cbi.rlf."..section.."."..self.option) and - not luci.http.formvalue("cbi.rlf."..section.."."..self.option..".x") + if not self.map:formvalue("cbi.rlf."..section.."."..self.option) and + not self.map:formvalue("cbi.rlf."..section.."."..self.option..".x") then return val end diff --git a/libs/sys/luasrc/sys/zoneinfo.lua b/libs/sys/luasrc/sys/zoneinfo.lua new file mode 100644 index 000000000..7bd02d934 --- /dev/null +++ b/libs/sys/luasrc/sys/zoneinfo.lua @@ -0,0 +1,408 @@ +--[[ +LuCI - Autogenerated Zoneinfo Module + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +]]-- + +module "luci.sys.zoneinfo" + +TZ = { + { 'Africa/Abidjan', 'GMT0' }, + { 'Africa/Accra', 'GMT0' }, + { 'Africa/Addis Ababa', 'EAT-3' }, + { 'Africa/Algiers', 'CET-1' }, + { 'Africa/Asmara', 'EAT-3' }, + { 'Africa/Bamako', 'GMT0' }, + { 'Africa/Bangui', 'WAT-1' }, + { 'Africa/Banjul', 'GMT0' }, + { 'Africa/Bissau', 'GMT0' }, + { 'Africa/Blantyre', 'CAT-2' }, + { 'Africa/Brazzaville', 'WAT-1' }, + { 'Africa/Bujumbura', 'CAT-2' }, + { 'Africa/Casablanca', 'WET0' }, + { 'Africa/Ceuta', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Africa/Conakry', 'GMT0' }, + { 'Africa/Dakar', 'GMT0' }, + { 'Africa/Dar es Salaam', 'EAT-3' }, + { 'Africa/Djibouti', 'EAT-3' }, + { 'Africa/Douala', 'WAT-1' }, + { 'Africa/El Aaiun', 'WET0' }, + { 'Africa/Freetown', 'GMT0' }, + { 'Africa/Gaborone', 'CAT-2' }, + { 'Africa/Harare', 'CAT-2' }, + { 'Africa/Johannesburg', 'SAST-2' }, + { 'Africa/Kampala', 'EAT-3' }, + { 'Africa/Khartoum', 'EAT-3' }, + { 'Africa/Kigali', 'CAT-2' }, + { 'Africa/Kinshasa', 'WAT-1' }, + { 'Africa/Lagos', 'WAT-1' }, + { 'Africa/Libreville', 'WAT-1' }, + { 'Africa/Lome', 'GMT0' }, + { 'Africa/Luanda', 'WAT-1' }, + { 'Africa/Lubumbashi', 'CAT-2' }, + { 'Africa/Lusaka', 'CAT-2' }, + { 'Africa/Malabo', 'WAT-1' }, + { 'Africa/Maputo', 'CAT-2' }, + { 'Africa/Maseru', 'SAST-2' }, + { 'Africa/Mbabane', 'SAST-2' }, + { 'Africa/Mogadishu', 'EAT-3' }, + { 'Africa/Monrovia', 'GMT0' }, + { 'Africa/Nairobi', 'EAT-3' }, + { 'Africa/Ndjamena', 'WAT-1' }, + { 'Africa/Niamey', 'WAT-1' }, + { 'Africa/Nouakchott', 'GMT0' }, + { 'Africa/Ouagadougou', 'GMT0' }, + { 'Africa/Porto-Novo', 'WAT-1' }, + { 'Africa/Sao Tome', 'GMT0' }, + { 'Africa/Tripoli', 'EET-2' }, + { 'Africa/Tunis', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Africa/Windhoek', 'WAT-1WAST,M9.1.0,M4.1.0' }, + { 'America/Adak', 'HAST10HADT,M3.2.0,M11.1.0' }, + { 'America/Anchorage', 'AKST9AKDT,M3.2.0,M11.1.0' }, + { 'America/Anguilla', 'AST4' }, + { 'America/Antigua', 'AST4' }, + { 'America/Araguaina', 'BRT3' }, + { 'America/Argentina/Buenos Aires', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Argentina/Catamarca', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Argentina/Cordoba', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Argentina/Jujuy', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Argentina/La Rioja', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Argentina/Mendoza', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Argentina/Rio Gallegos', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Argentina/San Juan', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Argentina/San Luis', 'ART3' }, + { 'America/Argentina/Tucuman', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Argentina/Ushuaia', 'ART3ARST,M10.1.0/0,M3.3.0/0' }, + { 'America/Aruba', 'AST4' }, + { 'America/Asuncion', 'PYT4PYST,M10.3.0/0,M3.2.0/0' }, + { 'America/Atikokan', 'EST5' }, + { 'America/Bahia', 'BRT3' }, + { 'America/Barbados', 'AST4' }, + { 'America/Belem', 'BRT3' }, + { 'America/Belize', 'CST6' }, + { 'America/Blanc-Sablon', 'AST4' }, + { 'America/Boa Vista', 'AMT4' }, + { 'America/Bogota', 'COT5' }, + { 'America/Boise', 'MST7MDT,M3.2.0,M11.1.0' }, + { 'America/Cambridge Bay', 'MST7MDT,M3.2.0,M11.1.0' }, + { 'America/Campo Grande', 'AMT4AMST,M10.2.0/0,M2.3.0/0' }, + { 'America/Cancun', 'CST6CDT,M4.1.0,M10.5.0' }, + { 'America/Caracas', 'VET4:30' }, + { 'America/Cayenne', 'GFT3' }, + { 'America/Cayman', 'EST5' }, + { 'America/Chicago', 'CST6CDT,M3.2.0,M11.1.0' }, + { 'America/Chihuahua', 'MST7MDT,M4.1.0,M10.5.0' }, + { 'America/Costa Rica', 'CST6' }, + { 'America/Cuiaba', 'AMT4AMST,M10.2.0/0,M2.3.0/0' }, + { 'America/Curacao', 'AST4' }, + { 'America/Danmarkshavn', 'GMT0' }, + { 'America/Dawson', 'PST8PDT,M3.2.0,M11.1.0' }, + { 'America/Dawson Creek', 'MST7' }, + { 'America/Denver', 'MST7MDT,M3.2.0,M11.1.0' }, + { 'America/Detroit', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Dominica', 'AST4' }, + { 'America/Edmonton', 'MST7MDT,M3.2.0,M11.1.0' }, + { 'America/Eirunepe', 'AMT4' }, + { 'America/El Salvador', 'CST6' }, + { 'America/Fortaleza', 'BRT3' }, + { 'America/Glace Bay', 'AST4ADT,M3.2.0,M11.1.0' }, + { 'America/Goose Bay', 'AST4ADT,M3.2.0/0:01,M11.1.0/0:01' }, + { 'America/Grand Turk', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Grenada', 'AST4' }, + { 'America/Guadeloupe', 'AST4' }, + { 'America/Guatemala', 'CST6' }, + { 'America/Guayaquil', 'ECT5' }, + { 'America/Guyana', 'GYT4' }, + { 'America/Halifax', 'AST4ADT,M3.2.0,M11.1.0' }, + { 'America/Havana', 'CST5CDT,M3.3.0/0,M10.5.0/1' }, + { 'America/Hermosillo', 'MST7' }, + { 'America/Indiana/Indianapolis', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Indiana/Knox', 'CST6CDT,M3.2.0,M11.1.0' }, + { 'America/Indiana/Marengo', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Indiana/Petersburg', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Indiana/Tell City', 'CST6CDT,M3.2.0,M11.1.0' }, + { 'America/Indiana/Vevay', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Indiana/Vincennes', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Indiana/Winamac', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Inuvik', 'MST7MDT,M3.2.0,M11.1.0' }, + { 'America/Iqaluit', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Jamaica', 'EST5' }, + { 'America/Juneau', 'AKST9AKDT,M3.2.0,M11.1.0' }, + { 'America/Kentucky/Louisville', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Kentucky/Monticello', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/La Paz', 'BOT4' }, + { 'America/Lima', 'PET5' }, + { 'America/Los Angeles', 'PST8PDT,M3.2.0,M11.1.0' }, + { 'America/Maceio', 'BRT3' }, + { 'America/Managua', 'CST6' }, + { 'America/Manaus', 'AMT4' }, + { 'America/Marigot', 'AST4' }, + { 'America/Martinique', 'AST4' }, + { 'America/Mazatlan', 'MST7MDT,M4.1.0,M10.5.0' }, + { 'America/Menominee', 'CST6CDT,M3.2.0,M11.1.0' }, + { 'America/Merida', 'CST6CDT,M4.1.0,M10.5.0' }, + { 'America/Mexico City', 'CST6CDT,M4.1.0,M10.5.0' }, + { 'America/Miquelon', 'PMST3PMDT,M3.2.0,M11.1.0' }, + { 'America/Moncton', 'AST4ADT,M3.2.0,M11.1.0' }, + { 'America/Monterrey', 'CST6CDT,M4.1.0,M10.5.0' }, + { 'America/Montevideo', 'UYT3UYST,M10.1.0,M3.2.0' }, + { 'America/Montreal', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Montserrat', 'AST4' }, + { 'America/Nassau', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/New York', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Nipigon', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Nome', 'AKST9AKDT,M3.2.0,M11.1.0' }, + { 'America/Noronha', 'FNT2' }, + { 'America/North Dakota/Center', 'CST6CDT,M3.2.0,M11.1.0' }, + { 'America/North Dakota/New Salem', 'CST6CDT,M3.2.0,M11.1.0' }, + { 'America/Panama', 'EST5' }, + { 'America/Pangnirtung', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Paramaribo', 'SRT3' }, + { 'America/Phoenix', 'MST7' }, + { 'America/Port of Spain', 'AST4' }, + { 'America/Port-au-Prince', 'EST5' }, + { 'America/Porto Velho', 'AMT4' }, + { 'America/Puerto Rico', 'AST4' }, + { 'America/Rainy River', 'CST6CDT,M3.2.0,M11.1.0' }, + { 'America/Rankin Inlet', 'CST6CDT,M3.2.0,M11.1.0' }, + { 'America/Recife', 'BRT3' }, + { 'America/Regina', 'CST6' }, + { 'America/Resolute', 'EST5' }, + { 'America/Rio Branco', 'AMT4' }, + { 'America/Santarem', 'BRT3' }, + { 'America/Santo Domingo', 'AST4' }, + { 'America/Sao Paulo', 'BRT3BRST,M10.2.0/0,M2.3.0/0' }, + { 'America/Scoresbysund', 'EGT1EGST,M3.5.0/0,M10.5.0/1' }, + { 'America/Shiprock', 'MST7MDT,M3.2.0,M11.1.0' }, + { 'America/St Barthelemy', 'AST4' }, + { 'America/St Johns', 'NST3:30NDT,M3.2.0/0:01,M11.1.0/0:01' }, + { 'America/St Kitts', 'AST4' }, + { 'America/St Lucia', 'AST4' }, + { 'America/St Thomas', 'AST4' }, + { 'America/St Vincent', 'AST4' }, + { 'America/Swift Current', 'CST6' }, + { 'America/Tegucigalpa', 'CST6' }, + { 'America/Thule', 'AST4ADT,M3.2.0,M11.1.0' }, + { 'America/Thunder Bay', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Tijuana', 'PST8PDT,M4.1.0,M10.5.0' }, + { 'America/Toronto', 'EST5EDT,M3.2.0,M11.1.0' }, + { 'America/Tortola', 'AST4' }, + { 'America/Vancouver', 'PST8PDT,M3.2.0,M11.1.0' }, + { 'America/Whitehorse', 'PST8PDT,M3.2.0,M11.1.0' }, + { 'America/Winnipeg', 'CST6CDT,M3.2.0,M11.1.0' }, + { 'America/Yakutat', 'AKST9AKDT,M3.2.0,M11.1.0' }, + { 'America/Yellowknife', 'MST7MDT,M3.2.0,M11.1.0' }, + { 'Antarctica/Casey', 'WST-8' }, + { 'Antarctica/Davis', 'DAVT-7' }, + { 'Antarctica/DumontDUrville', 'DDUT-10' }, + { 'Antarctica/Mawson', 'MAWT-6' }, + { 'Antarctica/McMurdo', 'NZST-12NZDT,M9.5.0,M4.1.0/3' }, + { 'Antarctica/Rothera', 'ROTT3' }, + { 'Antarctica/South Pole', 'NZST-12NZDT,M9.5.0,M4.1.0/3' }, + { 'Antarctica/Syowa', 'SYOT-3' }, + { 'Antarctica/Vostok', 'VOST-6' }, + { 'Arctic/Longyearbyen', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Asia/Aden', 'AST-3' }, + { 'Asia/Almaty', 'ALMT-6' }, + { 'Asia/Amman', 'EET-2EEST,M3.5.4/0,M10.5.5/1' }, + { 'Asia/Anadyr', 'ANAT-12ANAST,M3.5.0,M10.5.0/3' }, + { 'Asia/Aqtau', 'AQTT-5' }, + { 'Asia/Aqtobe', 'AQTT-5' }, + { 'Asia/Ashgabat', 'TMT-5' }, + { 'Asia/Baghdad', 'AST-3' }, + { 'Asia/Bahrain', 'AST-3' }, + { 'Asia/Baku', 'AZT-4AZST,M3.5.0/4,M10.5.0/5' }, + { 'Asia/Bangkok', 'ICT-7' }, + { 'Asia/Beirut', 'EET-2EEST,M3.5.0/0,M10.5.0/0' }, + { 'Asia/Bishkek', 'KGT-6' }, + { 'Asia/Brunei', 'BNT-8' }, + { 'Asia/Choibalsan', 'CHOT-8' }, + { 'Asia/Chongqing', 'CST-8' }, + { 'Asia/Colombo', 'IST-5:30' }, + { 'Asia/Damascus', 'EET-2EEST,M4.1.5/0,J274/0' }, + { 'Asia/Dhaka', 'BDT-6' }, + { 'Asia/Dili', 'TLT-9' }, + { 'Asia/Dubai', 'GST-4' }, + { 'Asia/Dushanbe', 'TJT-5' }, + { 'Asia/Gaza', 'EET-2EEST,J91/0,M9.2.4' }, + { 'Asia/Harbin', 'CST-8' }, + { 'Asia/Ho Chi Minh', 'ICT-7' }, + { 'Asia/Hong Kong', 'HKT-8' }, + { 'Asia/Hovd', 'HOVT-7' }, + { 'Asia/Irkutsk', 'IRKT-8IRKST,M3.5.0,M10.5.0/3' }, + { 'Asia/Jakarta', 'WIT-7' }, + { 'Asia/Jayapura', 'EIT-9' }, + { 'Asia/Kabul', 'AFT-4:30' }, + { 'Asia/Kamchatka', 'PETT-12PETST,M3.5.0,M10.5.0/3' }, + { 'Asia/Karachi', 'PKT-5' }, + { 'Asia/Kashgar', 'CST-8' }, + { 'Asia/Katmandu', 'NPT-5:45' }, + { 'Asia/Kolkata', 'IST-5:30' }, + { 'Asia/Krasnoyarsk', 'KRAT-7KRAST,M3.5.0,M10.5.0/3' }, + { 'Asia/Kuala Lumpur', 'MYT-8' }, + { 'Asia/Kuching', 'MYT-8' }, + { 'Asia/Kuwait', 'AST-3' }, + { 'Asia/Macau', 'CST-8' }, + { 'Asia/Magadan', 'MAGT-11MAGST,M3.5.0,M10.5.0/3' }, + { 'Asia/Makassar', 'CIT-8' }, + { 'Asia/Manila', 'PHT-8' }, + { 'Asia/Muscat', 'GST-4' }, + { 'Asia/Nicosia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Asia/Novosibirsk', 'NOVT-6NOVST,M3.5.0,M10.5.0/3' }, + { 'Asia/Omsk', 'OMST-6OMSST,M3.5.0,M10.5.0/3' }, + { 'Asia/Oral', 'ORAT-5' }, + { 'Asia/Phnom Penh', 'ICT-7' }, + { 'Asia/Pontianak', 'WIT-7' }, + { 'Asia/Pyongyang', 'KST-9' }, + { 'Asia/Qatar', 'AST-3' }, + { 'Asia/Qyzylorda', 'QYZT-6' }, + { 'Asia/Rangoon', 'MMT-6:30' }, + { 'Asia/Riyadh', 'AST-3' }, + { 'Asia/Sakhalin', 'SAKT-10SAKST,M3.5.0,M10.5.0/3' }, + { 'Asia/Samarkand', 'UZT-5' }, + { 'Asia/Seoul', 'KST-9' }, + { 'Asia/Shanghai', 'CST-8' }, + { 'Asia/Singapore', 'SGT-8' }, + { 'Asia/Taipei', 'CST-8' }, + { 'Asia/Tashkent', 'UZT-5' }, + { 'Asia/Tbilisi', 'GET-4' }, + { 'Asia/Thimphu', 'BTT-6' }, + { 'Asia/Tokyo', 'JST-9' }, + { 'Asia/Ulaanbaatar', 'ULAT-8' }, + { 'Asia/Urumqi', 'CST-8' }, + { 'Asia/Vientiane', 'ICT-7' }, + { 'Asia/Vladivostok', 'VLAT-10VLAST,M3.5.0,M10.5.0/3' }, + { 'Asia/Yakutsk', 'YAKT-9YAKST,M3.5.0,M10.5.0/3' }, + { 'Asia/Yekaterinburg', 'YEKT-5YEKST,M3.5.0,M10.5.0/3' }, + { 'Asia/Yerevan', 'AMT-4AMST,M3.5.0,M10.5.0/3' }, + { 'Atlantic/Azores', 'AZOT1AZOST,M3.5.0/0,M10.5.0/1' }, + { 'Atlantic/Bermuda', 'AST4ADT,M3.2.0,M11.1.0' }, + { 'Atlantic/Canary', 'WET0WEST,M3.5.0/1,M10.5.0' }, + { 'Atlantic/Cape Verde', 'CVT1' }, + { 'Atlantic/Faroe', 'WET0WEST,M3.5.0/1,M10.5.0' }, + { 'Atlantic/Madeira', 'WET0WEST,M3.5.0/1,M10.5.0' }, + { 'Atlantic/Reykjavik', 'GMT0' }, + { 'Atlantic/South Georgia', 'GST2' }, + { 'Atlantic/St Helena', 'GMT0' }, + { 'Atlantic/Stanley', 'FKT4FKST,M9.1.0,M4.3.0' }, + { 'Australia/Adelaide', 'CST-9:30CST,M10.1.0,M4.1.0/3' }, + { 'Australia/Brisbane', 'EST-10' }, + { 'Australia/Broken Hill', 'CST-9:30CST,M10.1.0,M4.1.0/3' }, + { 'Australia/Currie', 'EST-10EST,M10.1.0,M4.1.0/3' }, + { 'Australia/Darwin', 'CST-9:30' }, + { 'Australia/Eucla', 'CWST-8:45' }, + { 'Australia/Hobart', 'EST-10EST,M10.1.0,M4.1.0/3' }, + { 'Australia/Lindeman', 'EST-10' }, + { 'Australia/Lord Howe', 'LHST-10:30LHST-11,M10.1.0,M4.1.0' }, + { 'Australia/Melbourne', 'EST-10EST,M10.1.0,M4.1.0/3' }, + { 'Australia/Perth', 'WST-8' }, + { 'Australia/Sydney', 'EST-10EST,M10.1.0,M4.1.0/3' }, + { 'Europe/Amsterdam', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Andorra', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Athens', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Belgrade', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Berlin', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Bratislava', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Brussels', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Bucharest', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Budapest', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Chisinau', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Copenhagen', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Dublin', 'GMT0IST,M3.5.0/1,M10.5.0' }, + { 'Europe/Gibraltar', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Guernsey', 'GMT0BST,M3.5.0/1,M10.5.0' }, + { 'Europe/Helsinki', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Isle of Man', 'GMT0BST,M3.5.0/1,M10.5.0' }, + { 'Europe/Istanbul', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Jersey', 'GMT0BST,M3.5.0/1,M10.5.0' }, + { 'Europe/Kaliningrad', 'EET-2EEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Kiev', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Lisbon', 'WET0WEST,M3.5.0/1,M10.5.0' }, + { 'Europe/Ljubljana', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/London', 'GMT0BST,M3.5.0/1,M10.5.0' }, + { 'Europe/Luxembourg', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Madrid', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Malta', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Mariehamn', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Minsk', 'EET-2EEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Monaco', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Moscow', 'MSK-3MSD,M3.5.0,M10.5.0/3' }, + { 'Europe/Oslo', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Paris', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Podgorica', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Prague', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Riga', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Rome', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Samara', 'SAMT-4SAMST,M3.5.0,M10.5.0/3' }, + { 'Europe/San Marino', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Sarajevo', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Simferopol', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Skopje', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Sofia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Stockholm', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Tallinn', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Tirane', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Uzhgorod', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Vaduz', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Vatican', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Vienna', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Vilnius', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Volgograd', 'VOLT-3VOLST,M3.5.0,M10.5.0/3' }, + { 'Europe/Warsaw', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Zagreb', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Europe/Zaporozhye', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, + { 'Europe/Zurich', 'CET-1CEST,M3.5.0,M10.5.0/3' }, + { 'Indian/Antananarivo', 'EAT-3' }, + { 'Indian/Chagos', 'IOT-6' }, + { 'Indian/Christmas', 'CXT-7' }, + { 'Indian/Cocos', 'CCT-6:30' }, + { 'Indian/Comoro', 'EAT-3' }, + { 'Indian/Kerguelen', 'TFT-5' }, + { 'Indian/Mahe', 'SCT-4' }, + { 'Indian/Maldives', 'MVT-5' }, + { 'Indian/Mauritius', 'MUT-4' }, + { 'Indian/Mayotte', 'EAT-3' }, + { 'Indian/Reunion', 'RET-4' }, + { 'Pacific/Apia', 'WST11' }, + { 'Pacific/Auckland', 'NZST-12NZDT,M9.5.0,M4.1.0/3' }, + { 'Pacific/Chatham', 'CHAST-12:45CHADT,M9.5.0/2:45,M4.1.0/3:45' }, + { 'Pacific/Efate', 'VUT-11' }, + { 'Pacific/Enderbury', 'PHOT-13' }, + { 'Pacific/Fakaofo', 'TKT10' }, + { 'Pacific/Fiji', 'FJT-12' }, + { 'Pacific/Funafuti', 'TVT-12' }, + { 'Pacific/Galapagos', 'GALT6' }, + { 'Pacific/Gambier', 'GAMT9' }, + { 'Pacific/Guadalcanal', 'SBT-11' }, + { 'Pacific/Guam', 'ChST-10' }, + { 'Pacific/Honolulu', 'HST10' }, + { 'Pacific/Johnston', 'HST10' }, + { 'Pacific/Kiritimati', 'LINT-14' }, + { 'Pacific/Kosrae', 'KOST-11' }, + { 'Pacific/Kwajalein', 'MHT-12' }, + { 'Pacific/Majuro', 'MHT-12' }, + { 'Pacific/Marquesas', 'MART9:30' }, + { 'Pacific/Midway', 'SST11' }, + { 'Pacific/Nauru', 'NRT-12' }, + { 'Pacific/Niue', 'NUT11' }, + { 'Pacific/Norfolk', 'NFT-11:30' }, + { 'Pacific/Noumea', 'NCT-11' }, + { 'Pacific/Pago Pago', 'SST11' }, + { 'Pacific/Palau', 'PWT-9' }, + { 'Pacific/Pitcairn', 'PST8' }, + { 'Pacific/Ponape', 'PONT-11' }, + { 'Pacific/Port Moresby', 'PGT-10' }, + { 'Pacific/Rarotonga', 'CKT10' }, + { 'Pacific/Saipan', 'ChST-10' }, + { 'Pacific/Tahiti', 'TAHT10' }, + { 'Pacific/Tarawa', 'GILT-12' }, + { 'Pacific/Tongatapu', 'TOT-13' }, + { 'Pacific/Truk', 'TRUT-10' }, + { 'Pacific/Wake', 'WAKT-12' }, + { 'Pacific/Wallis', 'WFT-12' }, +} diff --git a/modules/admin-core/root/lib/uci/schema/default/system b/modules/admin-core/root/lib/uci/schema/default/system index 6ce96e573..28fee1c2e 100644 --- a/modules/admin-core/root/lib/uci/schema/default/system +++ b/modules/admin-core/root/lib/uci/schema/default/system @@ -17,6 +17,11 @@ config variable option datatype 'hostname' option required true +config variable + option name 'zonename' + option title 'Option zonename' + option section 'system.system' + config variable option name 'timezone' option title 'Option timezone' diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua b/modules/admin-full/luasrc/model/cbi/admin_system/system.lua index e0e2b1cbc..9820cceb2 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_system/system.lua @@ -11,8 +11,9 @@ You may obtain a copy of the License at $Id$ ]]-- -require("luci.http.protocol.date") + require("luci.sys") +require("luci.sys.zoneinfo") require("luci.tools.webadmin") m = Map("system", translate("system"), translate("a_s_desc")) @@ -48,17 +49,22 @@ s:option(DummyValue, "_uptime", translate("m_i_uptime")).value = s:option(Value, "hostname", translate("hostname")) -tz = s:option(Value, "timezone", translate("timezone")) -for k, offset in luci.util.vspairs(luci.http.protocol.date.TZ) do - local zone = k:upper() - local osgn = (offset >= 0 and "" or "+") - local ohrs = math.floor(-offset / 3600) - local omin = (offset % 3600) / 60 - - local ptz = zone .. osgn .. (ohrs ~= 0 and ohrs or "") .. (omin ~= 0 and ":" .. omin or "") - local dtz = string.format("%+03d:%02d ", ohrs, omin) .. zone - - tz:value(ptz, dtz) +tz = s:option(ListValue, "zonename", translate("timezone")) +tz:value("UTC") + +for i, zone in ipairs(luci.sys.zoneinfo.TZ) do + tz:value(zone[1]) +end + +function tz.write(self, section, value) + local function lookup_zone(title) + for _, zone in ipairs(luci.sys.zoneinfo.TZ) do + if zone[1] == title then return zone[2] end + end + end + + AbstractValue.write(self, section, value) + self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0") end s:option(Value, "log_size", nil, "kiB").optional = true diff --git a/modules/admin-mini/luasrc/model/cbi/mini/system.lua b/modules/admin-mini/luasrc/model/cbi/mini/system.lua index a1ed1282c..5c06a0fbe 100644 --- a/modules/admin-mini/luasrc/model/cbi/mini/system.lua +++ b/modules/admin-mini/luasrc/model/cbi/mini/system.lua @@ -11,8 +11,9 @@ You may obtain a copy of the License at $Id$ ]]-- -require("luci.http.protocol.date") + require("luci.sys") +require("luci.sys.zoneinfo") require("luci.tools.webadmin") @@ -49,23 +50,24 @@ s:option(DummyValue, "_systime", translate("m_i_systemtime")).value = s:option(DummyValue, "_uptime", translate("m_i_uptime")).value = luci.tools.webadmin.date_format(tonumber(uptime)) - - - - s:option(Value, "hostname", translate("hostname")) -tz = s:option(Value, "timezone", translate("timezone")) -for k, offset in luci.util.vspairs(luci.http.protocol.date.TZ) do - local zone = k:upper() - local osgn = (offset >= 0 and "" or "+") - local ohrs = math.floor(-offset / 3600) - local omin = (offset % 3600) / 60 - - local ptz = zone .. osgn .. (ohrs ~= 0 and ohrs or "") .. (omin ~= 0 and ":" .. omin or "") - local dtz = string.format("%+03d:%02d ", ohrs, omin) .. zone - - tz:value(ptz, dtz) +tz = s:option(ListValue, "zonename", translate("timezone")) +tz:value("UTC") + +for i, zone in ipairs(luci.sys.zoneinfo.TZ) do + tz:value(zone[1]) +end + +function tz.write(self, section, value) + local function lookup_zone(title) + for _, zone in ipairs(luci.sys.zoneinfo.TZ) do + if zone[1] == title then return zone[2] end + end + end + + AbstractValue.write(self, section, value) + self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0") end return m -- 2.25.1