Skip to content

Commit ce5fa40

Browse files
authored
Merge pull request #9515 from jchristgit/export-timer-time-type
Export timer:time/0 type as a nominal OTP-19526
2 parents 55a9003 + a75ae91 commit ce5fa40

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/stdlib/src/timer.erl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ done
154154
code_change/3, handle_cast/2, terminate/2]).
155155

156156
%% Types which can be used by other modules
157-
-export_type([tref/0]).
157+
-export_type([tref/0, time/0]).
158158

159159
%% Max value for a receive's after clause.
160160
-define(MAX_RECEIVE_AFTER, 16#ffffffff).
@@ -171,8 +171,10 @@ done
171171
-doc "A timer reference.".
172172
-opaque tref() :: {type(), reference()}.
173173
-type type() :: 'once' | 'interval' | 'instant' | 'send_local'.
174+
174175
-doc "Time in milliseconds.".
175-
-type time() :: non_neg_integer().
176+
-doc #{since => ~"OTP @OTP-19526@"}.
177+
-nominal time() :: non_neg_integer().
176178

177179
%%
178180
%% Interface functions
@@ -678,21 +680,21 @@ now_diff({A2, B2, C2}, {A1, B1, C1}) ->
678680
-doc "Returns the number of milliseconds in `Seconds`.".
679681
-spec seconds(Seconds) -> MilliSeconds
680682
when Seconds :: non_neg_integer(),
681-
MilliSeconds :: non_neg_integer().
683+
MilliSeconds :: time().
682684
seconds(Seconds) ->
683685
1000*Seconds.
684686

685687
-doc "Returns the number of milliseconds in `Minutes`.".
686688
-spec minutes(Minutes) -> MilliSeconds
687689
when Minutes :: non_neg_integer(),
688-
MilliSeconds :: non_neg_integer().
690+
MilliSeconds :: time().
689691
minutes(Minutes) ->
690692
1000*60*Minutes.
691693

692694
-doc "Returns the number of milliseconds in `Hours`.".
693695
-spec hours(Hours) -> MilliSeconds
694696
when Hours :: non_neg_integer(),
695-
MilliSeconds :: non_neg_integer().
697+
MilliSeconds :: time().
696698
hours(Hours) ->
697699
1000*60*60*Hours.
698700

@@ -701,7 +703,7 @@ hours(Hours) ->
701703
when Hours :: non_neg_integer(),
702704
Minutes :: non_neg_integer(),
703705
Seconds :: non_neg_integer(),
704-
MilliSeconds :: non_neg_integer().
706+
MilliSeconds :: time().
705707
hms(H, M, S) ->
706708
hours(H) + minutes(M) + seconds(S).
707709

0 commit comments

Comments
 (0)