Skip to content

Instantly share code, notes, and snippets.

@sinkovsky
Created September 17, 2014 10:07
Show Gist options
  • Save sinkovsky/66b7c988c6d9aaab752d to your computer and use it in GitHub Desktop.
Save sinkovsky/66b7c988c6d9aaab752d to your computer and use it in GitHub Desktop.
%%
%% Convert seconds, minutes etc. to milliseconds.
%%
-spec seconds(Seconds) -> MilliSeconds when
Seconds :: non_neg_integer(),
MilliSeconds :: non_neg_integer().
seconds(Seconds) ->
1000*Seconds.
-spec minutes(Minutes) -> MilliSeconds when
Minutes :: non_neg_integer(),
MilliSeconds :: non_neg_integer().
minutes(Minutes) ->
1000*60*Minutes.
-spec hours(Hours) -> MilliSeconds when
Hours :: non_neg_integer(),
MilliSeconds :: non_neg_integer().
hours(Hours) ->
1000*60*60*Hours.
-spec hms(Hours, Minutes, Seconds) -> MilliSeconds when
Hours :: non_neg_integer(),
Minutes :: non_neg_integer(),
Seconds :: non_neg_integer(),
MilliSeconds :: non_neg_integer().
hms(H, M, S) ->
hours(H) + minutes(M) + seconds(S).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment