lots of gutting. purposes, input, and output were unclear in many places. still broken.

This commit is contained in:
aj
2010-11-08 01:29:15 -08:00
parent 9ad8f3c826
commit d00937c3e9
13 changed files with 828 additions and 552 deletions

View File

@@ -2,22 +2,40 @@
-include("include/ezic.hrl").
-export([parse/1]).
-export([next_event/4]).
parse([Name,FromS,ToS,_Type,InS,OnS,AtS,SaveS,Letters]) ->
From= ezic_parse:year(FromS),
To= ezic_parse:year(ToS),
% @todo handle year types
In= ezic_date:month_to_num(InS),
On= ezic_parse:day_pattern(OnS),
At= ezic_parse:time(AtS),
Save= ezic_parse:time_val(SaveS),
Rule= #rule{name=Name, from=From, to=To, type=not_done,
in=In, on=On, at=At, save=Save, letters=Letters},
{ok, Rule}.
% determines the next zone or dst change event
% returns the latest possible times the previous period is in effect (`Until -1sec` in most cases)
% Rules are sorted
next_event(BaseFlat, ZoneEnd, Offset, []) ->
next_event(_BaseFlat, ZoneEnd, Offset, []) ->
{end_until, make_times(ZoneEnd, Offset)};
% BaseFlat has offset defined
% @todo ensure offset defined on BaseFlat
% Rules are sorted in ascending order (oldest first)
next_event(BaseFlat=#flatzone{utc_from=#tztime{time={{Year,_,_},_}}},
ZoneEnd, ZoneOffset, [Rule|RestRules]) ->
next_event(_BaseFlat=#flatzone{utc_from=#tztime{time={{_Year,_,_},_}}},
_ZoneEnd, _ZoneOffset, [_Rule|_RestRules]) ->
not_done.
@@ -38,3 +56,11 @@ make_times(Until, Offset, DSTOffset) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% INTERNAL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%