Skip to content

Commit 77ab395

Browse files
committed
Clarify calendar microseconds example
1 parent 72ff75c commit 77ab395

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

lib/elixir/lib/calendar.ex

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,19 @@ defmodule Calendar do
5858
@typedoc """
5959
Microseconds with stored precision.
6060
61+
`value` always represents the total value in microseconds.
62+
6163
The `precision` represents the number of digits that must be used when
6264
representing the microseconds to external format. If the precision is `0`,
6365
it means microseconds must be skipped. If the precision is `6`, it means
6466
that `value` represents exactly the number of microseconds to be used.
6567
66-
The formula to calculate microseconds from this type is:
67-
68-
microseconds = value * Integer.pow(10, 6 - precision)
69-
7068
## Examples
7169
7270
* `{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).
71+
* `{1, 6}` means 1µs.
72+
* `{1000, 6}` means 1000µs (which is 1ms but measured at the microsecond precision).
73+
* `{1000, 3}` means 1ms (which is measured at the millisecond precision).
7974
8075
"""
8176
@type microsecond :: {value :: non_neg_integer, precision :: non_neg_integer}

lib/elixir/lib/inspect/algebra.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ defmodule Inspect.Algebra do
333333
(is_tuple(doc) and elem(doc, 0) in @docs)
334334

335335
defguardp is_limit(limit) when limit == :infinity or (is_integer(limit) and limit >= 0)
336-
defguardp is_width(limit) when limit == :infinity or (is_integer(limit) and limit >= 0)
336+
defguardp is_width(width) when width == :infinity or (is_integer(width) and width >= 0)
337337

338338
# Elixir + Inspect.Opts conveniences
339339
# These have the _doc suffix.

0 commit comments

Comments
 (0)