diff --git a/src/luerl_lib_os.erl b/src/luerl_lib_os.erl index 441b5f4..dc85d65 100644 --- a/src/luerl_lib_os.erl +++ b/src/luerl_lib_os.erl @@ -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(),