fixed bug with rule choice; dst was not being calculated correctly, Thanks Adelaide!
This commit is contained in:
16
src/ezic.erl
16
src/ezic.erl
@@ -11,27 +11,27 @@
|
||||
|
||||
|
||||
localtime(TzName) ->
|
||||
Now= erlang:universaltime(),
|
||||
time(erlang:universaltime(), TzName).
|
||||
|
||||
|
||||
time(Datetime, TzName) ->
|
||||
|
||||
Zones= ezic_db:zones(TzName),
|
||||
% ?debug("All Zones: ~p", [Zones]),
|
||||
CZone= ezic_zone:current(Now, Zones),
|
||||
CZone= ezic_zone:current(Datetime, Zones),
|
||||
% ?debug("Current Zone: ~p", [CZone]),
|
||||
|
||||
RuleName= CZone#zone.rule,
|
||||
Rules= ezic_db:rules(RuleName),
|
||||
% ?debug("All Rules: ~p", [Rules]),
|
||||
CRule= ezic_rule:current(Now, Rules),
|
||||
CRule= ezic_rule:current(Datetime, Rules),
|
||||
% ?debug("Current Rule: ~p", [CRule]),
|
||||
|
||||
|
||||
OffsetSec= ezic_zone:offset_sec(CZone),
|
||||
DSTSec= ezic_rule:dst_sec(CRule),
|
||||
%
|
||||
|
||||
SecDiff= OffsetSec + DSTSec,
|
||||
?gs2dt(?dt2gs(Now) + SecDiff).
|
||||
|
||||
?gs2dt(?dt2gs(Datetime) + SecDiff).
|
||||
|
||||
|
||||
|
||||
@@ -56,4 +56,4 @@ test() ->
|
||||
fun(TZ)->
|
||||
io:format("~s: ~p~n", [TZ, localtime(TZ)])
|
||||
end,
|
||||
["Asia/Tokyo", "America/New_York", "America/Los_Angeles", "America/Jamaica"]).
|
||||
["Asia/Tokyo", "America/New_York", "America/Los_Angeles", "America/Jamaica", "Australia/Adelaide"]).
|
||||
|
||||
@@ -19,10 +19,11 @@ current(Now, Rules) ->
|
||||
|
||||
|
||||
|
||||
% newest first
|
||||
sort(R1, R2) ->
|
||||
T1= from_time(R1),
|
||||
T2= from_time(R2),
|
||||
ezic_date:compare_datetimes(T1, T2).
|
||||
ezic_date:compare_datetimes(T2, T1).
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user