Skip to content

Commit

Permalink
report missing required field explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
steveims committed May 9, 2024
1 parent 9540c33 commit 5855e4f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/luerl_lib_os.erl
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,13 @@ compute_time(Map=#{<<"year">> := Y, <<"month">> := Mth, <<"day">> := D}, _, St)
LocalEpoch = calendar:universal_time_to_local_time({{1970,1,1},{0,0,0}}),
Result = calendar:datetime_to_gregorian_seconds({{Y, Mth, D}, {H, Min, S}}) - calendar:datetime_to_gregorian_seconds(LocalEpoch),
{[Result],St};
compute_time(_, As, St) ->
badarg_error(time, As, St).
compute_time(Map, _As, St) ->
MissingArg = lists:foldl(fun(K,Acc=undefined) -> case maps:is_key(K, Map) of
false -> K;
true -> Acc
end;
(_,Acc) -> Acc end, undefined, [<<"day">>, <<"month">>, <<"year">>]),
badarg_error(time, MissingArg, St).

current_timestamp() ->
{Mega,Sec,Micro} = os:timestamp(),
Expand Down

0 comments on commit 5855e4f

Please sign in to comment.