modules/admin-full: apply timezone immediately (#103)
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_system / system.lua
index 99ab64d..a2bbf29 100644 (file)
@@ -15,6 +15,7 @@ $Id$
 require("luci.sys")
 require("luci.sys.zoneinfo")
 require("luci.tools.webadmin")
+require("luci.fs")
 
 m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
 
@@ -36,11 +37,11 @@ s:option(DummyValue, "_memtotal", translate("Memory")).value =
  string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
   tonumber(memtotal) / 1024,
   100 * memcached / memtotal,
-  tostring(translate("mem_cached", "")),
+  tostring(translate("cached")),
   100 * membuffers / memtotal,
-  tostring(translate("mem_buffered", "")),
+  tostring(translate("buffered")),
   100 * memfree / memtotal,
-  tostring(translate("mem_free", ""))
+  tostring(translate("free"))
 )
 
 s:option(DummyValue, "_systime", translate("Local Time")).value =
@@ -72,7 +73,9 @@ function tz.write(self, section, value)
        end
 
        AbstractValue.write(self, section, value)
-       self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0")
+       local timezone = lookup_zone(value) or "GMT0"
+       self.map.uci:set("system", section, "timezone", timezone)
+       luci.fs.writefile("/etc/TZ", timezone .. "\n")
 end
 
 s:option(Value, "log_size", nil, "kiB").optional = true