[api] define time constants
This commit is contained in:
parent
f8ba3937bb
commit
5ec3d9c92e
|
@ -16,6 +16,14 @@
|
||||||
%%%
|
%%%
|
||||||
%% @doc Common record definitions and helper functions for the Flukso API.
|
%% @doc Common record definitions and helper functions for the Flukso API.
|
||||||
|
|
||||||
|
-define(MINUTE, 60).
|
||||||
|
-define(QUARTER, 900).
|
||||||
|
-define(HOUR, 3600).
|
||||||
|
-define(DAY, 86400).
|
||||||
|
-define(WEEK, 604800).
|
||||||
|
-define(MONTH, 2419200).
|
||||||
|
-define(YEAR, 31536000).
|
||||||
|
|
||||||
-record(state,
|
-record(state,
|
||||||
{rrdSensor,
|
{rrdSensor,
|
||||||
rrdStart,
|
rrdStart,
|
||||||
|
@ -136,14 +144,14 @@ default_resolution(Interval) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
time_to_seconds(Time) ->
|
time_to_seconds(Time) ->
|
||||||
Times = [{"minute", 60},
|
Times = [{"minute", ?MINUTE},
|
||||||
{"15min", 900},
|
{"15min", ?QUARTER},
|
||||||
{"hour", 3600},
|
{"hour", ?HOUR},
|
||||||
{"day", 86400},
|
{"day", ?DAY},
|
||||||
{"week", 604800},
|
{"week", ?WEEK},
|
||||||
{"month", 2419200},
|
{"month", ?MONTH},
|
||||||
{"year", 31536000},
|
{"year", ?YEAR},
|
||||||
{"night", 2419200}],
|
{"night", ?MONTH}],
|
||||||
|
|
||||||
case lists:keyfind(Time, 1, Times) of
|
case lists:keyfind(Time, 1, Times) of
|
||||||
false -> false;
|
false -> false;
|
||||||
|
|
Loading…
Reference in New Issue