Skip to content

Commit 3c2cc4e

Browse files
authored
docs: clarify number-to-time conversion in durations.adoc (#211)
Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com> Co-authored-by: SAY-5 <SAY-5@users.noreply.github.com>
1 parent bd698d3 commit 3c2cc4e

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

docs/durations.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,14 @@ NOTE: TODO Don't forget you can create zone-offsets from durations!
6666
NOTE: TODO Don't forget you can create instants from durations - this is often needed when you get Unix times (e.g. JWT OAuth2 tokens)
6767
6868
The problem with numeric times is that there are cases where the units
69-
are in seconds and cases where milliseconds are used. If _tick_ were
70-
to convert numbers to times, it would be a source of confusion and
71-
bugs if the units were not clear. For this reason, you cannot convert
72-
numbers to times. However, you can first create the duration from the
73-
number, specifying the units explicitly, and then convert the duration
74-
to an `instant` (or `inst`).
69+
are in seconds and cases where milliseconds are used. To avoid ambiguity
70+
about the units, the recommended approach is to first create the duration
71+
from the number, specifying the units explicitly, and then convert the
72+
duration to an `instant` (or `inst`).
73+
74+
NOTE: `t/instant` does accept a bare number for convenience, treating it
75+
as epoch milliseconds. The duration-based form below is preferred because
76+
the units are explicit.
7577
7678
[source.code,clojure]
7779
----

docs/index.html

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<meta name="generator" content="Asciidoctor 2.0.18">
7+
<meta name="generator" content="Asciidoctor 2.0.26">
88
<meta name="author" content="Malcolm Sparks, Henry Widd, Johanna Antonelli">
99
<link rel="icon" type="image/x-icon" href="favicon.ico">
1010
<title>tick</title>
@@ -2212,12 +2212,24 @@ <h3 id="_misc">5.4. Misc</h3>
22122212
</div>
22132213
<div class="paragraph">
22142214
<p>The problem with numeric times is that there are cases where the units
2215-
are in seconds and cases where milliseconds are used. If <em>tick</em> were
2216-
to convert numbers to times, it would be a source of confusion and
2217-
bugs if the units were not clear. For this reason, you cannot convert
2218-
numbers to times. However, you can first create the duration from the
2219-
number, specifying the units explicitly, and then convert the duration
2220-
to an <code>instant</code> (or <code>inst</code>).</p>
2215+
are in seconds and cases where milliseconds are used. To avoid ambiguity
2216+
about the units, the recommended approach is to first create the duration
2217+
from the number, specifying the units explicitly, and then convert the
2218+
duration to an <code>instant</code> (or <code>inst</code>).</p>
2219+
</div>
2220+
<div class="admonitionblock note">
2221+
<table>
2222+
<tr>
2223+
<td class="icon">
2224+
<div class="title">Note</div>
2225+
</td>
2226+
<td class="content">
2227+
<code>t/instant</code> does accept a bare number for convenience, treating it
2228+
as epoch milliseconds. The duration-based form below is preferred because
2229+
the units are explicit.
2230+
</td>
2231+
</tr>
2232+
</table>
22212233
</div>
22222234
<div class="listingblock code">
22232235
<div class="content">

0 commit comments

Comments
 (0)