lookup by abbreviation added

This commit is contained in:
Dmitry Melnikov 2010-12-18 21:07:15 +03:00
parent d7c1630494
commit e47c340b97
3 changed files with 368 additions and 5 deletions

24
src/ibuild.erl Normal file
View file

@ -0,0 +1,24 @@
-module(ibuild).
-export([build_index/0]).
-include("tz_database.hrl").
build_tzlist(TzName, Name, Dict) ->
case dict:find(Name, Dict) of
error ->
dict:store(Name, [TzName], Dict);
{ok, TzNames} ->
dict:store(Name, TzNames ++ [TzName], Dict)
end.
build_index() ->
F = fun({TzName,{Name,_},{DName,_},_,_,_,_,_,_}, Acc) ->
NewDict = build_tzlist(TzName, Name, Acc),
build_tzlist(TzName, DName, NewDict);
({TzName,{Name,_},undef,_,_,_,_,_,_}, Acc) ->
build_tzlist(TzName, Name, Acc)
end,
I = lists:foldl(F, dict:new(), ?tz_database),
{ok, File} = file:open("tz_index.hrl", [write]),
io:fwrite(File, "-define(tz_index, ~p).", [I]).