max_year base case bug fixed. ezic:localtime/1 works.
the final flatzone for every Zone should end at "current" for every *_to time. This is inaccurate, but accuracy is only guaranteed up to ?MAX_YEAR (=2500 by default). that working, I fleshed out the few methods required to get ezic:utc_to_localtime/2 working, thus localtime/1 working. I've only tested localtime/1 at this point. additionally, mnesia appears to have its data corrupted every time I stop and start a node. I've got to read up on working with mnesia; it's not behaving as I would expect.
This commit is contained in:
@@ -13,7 +13,10 @@
|
||||
-define(MAXYEAR, 2500). % last year to process flatzones for.
|
||||
|
||||
|
||||
-export([flatten/0]).
|
||||
-export([
|
||||
flatten/0
|
||||
, contains_date/2
|
||||
]).
|
||||
|
||||
|
||||
%% debug
|
||||
@@ -27,6 +30,12 @@ flatten() ->
|
||||
done.
|
||||
|
||||
|
||||
contains_date(FlatZone, Date) ->
|
||||
NDate= ezic_date:normalize(Date),
|
||||
contains_date2(FlatZone, NDate).
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% PRIVATE
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@@ -47,8 +56,20 @@ flatten_all_zones([Z1|_]= AllZones) ->
|
||||
|
||||
|
||||
|
||||
contains_date2(FlatZone=#flatzone{utc_from=From, utc_to=To}, {Dt,#tztime{time=T, flag=F}})
|
||||
when F=:= u; F=:= g; F=:=z ->
|
||||
Date={Dt, T},
|
||||
ezic_date:compare(From, Date) andalso ezic_date:compare(Date, To);
|
||||
|
||||
|
||||
contains_date2(FlatZone=#flatzone{std_from=From, std_to=To}, {Dt,#tztime{time=T, flag=s}}) ->
|
||||
Date={Dt, T},
|
||||
ezic_date:compare(From, Date) andalso ezic_date:compare(Date, To);
|
||||
|
||||
contains_date2(FlatZone=#flatzone{wall_from=From, wall_to=To}, {Dt,#tztime{time=T, flag=F}})
|
||||
when F=:=w; F=:=undefined ->
|
||||
Date={Dt, T},
|
||||
ezic_date:compare(From, Date) andalso ezic_date:compare(Date, To).
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -161,7 +182,9 @@ flatten_rule_set(FlatStart=#flatzone{utc_from=UTCFrom, dstoffset=DSTOffset, offs
|
||||
try maxyear_reached(UTCEndingRuleDate) andalso maxyear_reached(ZoneDate) of
|
||||
true ->
|
||||
?debugMsg("maxyear reached from flatten_rule_set"),
|
||||
{Flats, #flatzone{utc_from=maximum}, none};
|
||||
{EndFlat, NextFlat}= finish_and_start_flat(max_year, FlatStart, DSTOffset),
|
||||
NewFlats= [EndFlat | Flats],
|
||||
{NewFlats, NextFlat, none};
|
||||
false ->
|
||||
|
||||
case ezic_date:compare(ZoneDate, UTCEndingRuleDate) of
|
||||
@@ -227,7 +250,14 @@ finish_and_start_flat(FlatStub=#flatzone{}, Zone=#zone{}, EndingDST) ->
|
||||
?debugVal(EndFlat),
|
||||
% ?debugVal(RetNextFlat),
|
||||
|
||||
{EndFlat, RetNextFlat}.
|
||||
{EndFlat, RetNextFlat};
|
||||
|
||||
finish_and_start_flat(max_year, FlatStub, DSTOffset) ->
|
||||
EndFlat= ?ENDFLAT(FlatStub, current, current, current, DSTOffset),
|
||||
Stop= {{?MAXYEAR+1,1,1},{0,0,0}},
|
||||
NextFlat= #flatzone{utc_from=Stop},
|
||||
{EndFlat, NextFlat}.
|
||||
|
||||
|
||||
|
||||
%% both timezone and rule are ending at the same time
|
||||
|
||||
Reference in New Issue
Block a user