Skip to content

Commit a47dc19

Browse files
authored
Improve docs for t:Calendar.microsecond/0 (#14426)
1 parent fdbc664 commit a47dc19

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/elixir/lib/calendar.ex

+18-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,25 @@ defmodule Calendar do
5858
@typedoc """
5959
Microseconds with stored precision.
6060
61-
The precision represents the number of digits that must be used when
61+
The `precision` represents the number of digits that must be used when
6262
representing the microseconds to external format. If the precision is `0`,
63-
it means microseconds must be skipped.
63+
it means microseconds must be skipped. If the precision is `6`, it means
64+
that `value` represents exactly the number of microseconds to be used.
65+
66+
The formula to calculate microseconds from this type is:
67+
68+
microseconds = value * Integer.pow(10, 6 - precision)
69+
70+
## Examples
71+
72+
* `{0, 0}` means no microseconds.
73+
* `{1, 6}` means 1µs (`value` is `1` and the precision specifies that six digits
74+
must be used).
75+
* `{93, 3}` means 93ms (`value` is `93` and the precision specifies that three digits
76+
must be used).
77+
* `{12, 2}` means 120ms (`value` is `12` and the precision specifies that two digits
78+
must be used).
79+
6480
"""
6581
@type microsecond :: {value :: non_neg_integer, precision :: non_neg_integer}
6682

0 commit comments

Comments
 (0)