Current section

Files

Jump to
diint_utilites_common_app src utilites time_utilites.erl
Raw

src/utilites/time_utilites.erl

%%%-------------------------------------------------------------------
%%% @author cheese
%%% @copyright (C) 2014, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 07. Apr 2014 9:40 AM
%%%-------------------------------------------------------------------
-module(time_utilites).
-author("cheese").
%% API
-export([get_seconds/1, time_to_string/1, timeout_seconds/1]).
get_seconds({{Year, Month, Day}, {Hour, Min, Second}}) ->
Second + Min * 60 + Hour * 3600 + Day * 86400 + Month * 2678400 + Year * 977616000.
time_to_string({{Year, Month, Day}, {Hour, Min, Second}}) ->
{{Year, Month, Day}, {Hour, Min, Second}},
list_to_binary(lists:flatten(io_lib:format("~B-~2.10.0B-~2.10.0B ~2.10.0B:~2.10.0B:~2.10.0B", [Year, Month, Day, Hour, Min, Second])));
time_to_string(_) ->
<<"undefined">>.
timeout_seconds(Seconds) ->
receive
illegal_message ->
ok
after Seconds*1000 ->
ok
end.