diff options
Diffstat (limited to 'src/plop_compat.erl')
-rw-r--r-- | src/plop_compat.erl | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/plop_compat.erl b/src/plop_compat.erl index 9a98e3d..4d45590 100644 --- a/src/plop_compat.erl +++ b/src/plop_compat.erl @@ -2,14 +2,17 @@ %%% See LICENSE for licensing information. -module(plop_compat). --export([unpack_spki/1, timestamp/0]). +-export([unpack_spki/1, timestamp/0, monotonic_time/1, start_timer/4]). -include_lib("public_key/include/public_key.hrl"). unpack_spki(SPKI) -> unpack_spki(erlang:system_info(otp_release), SPKI). timestamp() -> timestamp(erlang:system_info(otp_release)). - +monotonic_time(Unit) -> + monotonic_time(erlang:system_info(otp_release), Unit). +start_timer(Time, Dest, Msg, Options) -> + start_timer(erlang:system_info(otp_release), Time, Dest, Msg, Options). unpack_spki("R16" ++ _, SPKI) -> #'SubjectPublicKeyInfo'{subjectPublicKey = {_, Octets}, @@ -37,3 +40,23 @@ timestamp("18") -> erlang:timestamp(); timestamp("19") -> erlang:timestamp(). + +monotonic_time("R16" ++ _, millisecond) -> + {MeS, S, MiS} = timestamp(), + MeS * 1000000 + S * 1000 + MiS; +monotonic_time("17", millisecond) -> + {MeS, S, MiS} = timestamp(), + MeS * 1000000 + S * 1000 + MiS; +monotonic_time("18", Unit) -> + erlang:monotonic_time(Unit); +monotonic_time("19", Unit) -> + erlang:monotonic_time(Unit). + +start_timer("R16" ++ _, Time, Dest, Msg, [{abs, true}]) -> + erlang:start_timer(max(0, Time - monotonic_time(millisecond)), Dest, Msg); +start_timer("17", Time, Dest, Msg, [{abs, true}]) -> + erlang:start_timer(max(0, Time - monotonic_time(millisecond)), Dest, Msg); +start_timer("18", Time, Dest, Msg, Options) -> + erlang:start_timer(Time, Dest, Msg, Options); +start_timer("19", Time, Dest, Msg, Options) -> + erlang:start_timer(Time, Dest, Msg, Options). |