]> git.madduck.net Git - etc/awesome.git/blobdiff - luatz/tzcache.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

luatz/parse.lua: Pass base to tonumber explicitly
[etc/awesome.git] / luatz / tzcache.lua
index 98ced26947a3d84e012cf1f4099e67c44a79899b..ae32dceddd08abf8eb65ac52b8eaaddea1260f6c 100644 (file)
@@ -2,34 +2,34 @@ local read_tzfile = require "luatz.tzfile".read_tzfile
 
 local base_zoneinfo_path = "/usr/share/zoneinfo/"
 local local_zoneinfo_path = "/etc/localtime"
-local tz_cache = { }
+local tz_cache = {}
 
-local function name_to_zoneinfo_path ( name )
+local function name_to_zoneinfo_path(name)
        if name == nil then
                return local_zoneinfo_path
-       elseif name:sub ( 1 , 1 ) == "/" then
+       elseif name:sub(1, 1) == "/" then
                return name
        else
                return base_zoneinfo_path .. name
        end
 end
 
-local function clear_tz_cache ( name )
-       tz_cache [ name_to_zoneinfo_path ( name ) ] = nil
+local function clear_tz_cache(name)
+       tz_cache[name_to_zoneinfo_path(name)] = nil
 end
 
-local function get_tz ( name )
-       local path = name_to_zoneinfo_path ( name )
+local function get_tz(name)
+       local path = name_to_zoneinfo_path(name)
        -- TODO: stat path
-       local tzinfo = tz_cache [ path ]
+       local tzinfo = tz_cache[path]
        if tzinfo == nil then
-               tzinfo = read_tzfile ( path )
-               tz_cache [ path ] = tzinfo
+               tzinfo = read_tzfile(path)
+               tz_cache[path] = tzinfo
        end
        return tzinfo
 end
 
 return {
-       get_tz = get_tz ;
-       clear_tz_cache = clear_tz_cache ;
+       get_tz = get_tz;
+       clear_tz_cache = clear_tz_cache;
 }