makes ezic:local_to_utc errors into values; updates tests accordingly
Like in d98eed, errors are now returned as values rather than crashing processes. This is a short-term solution for consistency, and can be refactored to a saner model later.
This commit is contained in:
18
src/ezic.erl
18
src/ezic.erl
@@ -27,13 +27,8 @@ utc_to_local(UTCDatetime, TzName) ->
|
||||
%% returns utc time for corresponding time in given timezone utc
|
||||
local_to_utc(LocalDatetime, TzName) ->
|
||||
NormalDatetime= ezic_date:normalize(LocalDatetime, w),
|
||||
#flatzone{offset=Offset, dstoffset=DSTOffset}= ezic_db:flatzone(NormalDatetime, TzName),
|
||||
local_to_utc_handleFlatzone(LocalDatetime, ezic_db:flatzone(NormalDatetime, TzName)).
|
||||
|
||||
ezic_date:add_offset(
|
||||
ezic_date:add_offset(
|
||||
LocalDatetime
|
||||
, Offset, {0,0,0})
|
||||
, DSTOffset, {0,0,0}).
|
||||
|
||||
|
||||
|
||||
@@ -49,3 +44,14 @@ utc_to_local_handleFlatzone(UTCDatetime, #flatzone{offset=Offset, dstoffset=DSTO
|
||||
UTCDatetime
|
||||
, Offset)
|
||||
, DSTOffset).
|
||||
|
||||
|
||||
local_to_utc_handleFlatzone(_, X={error, _}) ->
|
||||
X;
|
||||
local_to_utc_handleFlatzone(LocalDatetime, #flatzone{offset=Offset, dstoffset=DSTOffset}) ->
|
||||
ezic_date:add_offset(
|
||||
ezic_date:add_offset(
|
||||
LocalDatetime
|
||||
, Offset, {0,0,0})
|
||||
, DSTOffset, {0,0,0}).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user