Skip to content

Commit 13f62d1

Browse files
committed
Rename "datetime" to "instant"
Other possibilities: "system-clock-point", "clock-point" (analogous to "monotonic-clock-point"), "exact-time", "absolute-time", "timestamp", "epoch-time".
1 parent e4521a3 commit 13f62d1

File tree

4 files changed

+40
-33
lines changed

4 files changed

+40
-33
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ default-monotonic-clock: monotonic-clock
8888
#### Retrieving the timezone:
8989

9090
```rust
91-
let datetime: Datetime = system_clock::now();
91+
let instant: Instant = system_clock::now();
9292

93-
let timezone_display: TimezoneDisplay = timezone::display(datetime);
93+
let timezone_display: TimezoneDisplay = timezone::display(instant);
9494

9595
println!("the timezone is {}", timezone_display.name);
9696
```

imports.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,20 @@ elapsed from the time this function is invoked.</p>
123123
time. The clock is not necessarily monotonic as it may be reset.</p>
124124
<p>It is intended to be portable at least between Unix-family platforms and
125125
Windows.</p>
126-
<p>A wall clock is a clock which measures the date and time according to
127-
some external reference.</p>
126+
<p>An &quot;instant&quot;, or &quot;exact time&quot;, is a point in time without regard to any time
127+
zone: just the time since a particular external reference point, often
128+
called an &quot;epoch&quot;.</p>
128129
<p>External references may be reset, so this clock is not necessarily
129130
monotonic, making it unsuitable for measuring elapsed time.</p>
130131
<p>It is intended for reporting the current date and time for humans.</p>
131132
<hr />
132133
<h3>Types</h3>
133-
<h4><a name="datetime"></a><code>record datetime</code></h4>
134-
<p>A time and date in seconds plus nanoseconds.</p>
134+
<h4><a name="instant"></a><code>record instant</code></h4>
135+
<p>An exact time in seconds plus nanoseconds.</p>
135136
<h5>Record Fields</h5>
136137
<ul>
137-
<li><a name="datetime.seconds"></a><code>seconds</code>: <code>u64</code></li>
138-
<li><a name="datetime.nanoseconds"></a><code>nanoseconds</code>: <code>u32</code></li>
138+
<li><a name="instant.seconds"></a><code>seconds</code>: <code>u64</code></li>
139+
<li><a name="instant.nanoseconds"></a><code>nanoseconds</code>: <code>u32</code></li>
139140
</ul>
140141
<hr />
141142
<h3>Functions</h3>
@@ -149,23 +150,24 @@ also known as <a href="https://en.wikipedia.org/wiki/Unix_time">Unix Time</a>.</
149150
<p>The nanoseconds field of the output is always less than 1000000000.</p>
150151
<h5>Return values</h5>
151152
<ul>
152-
<li><a name="now.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
153+
<li><a name="now.0"></a> <a href="#instant"><a href="#instant"><code>instant</code></a></a></li>
153154
</ul>
154155
<h4><a name="resolution"></a><code>resolution: func</code></h4>
155156
<p>Query the resolution of the clock.</p>
156157
<p>The nanoseconds field of the output is always less than 1000000000.</p>
157158
<h5>Return values</h5>
158159
<ul>
159-
<li><a name="resolution.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
160+
<li><a name="resolution.0"></a> <a href="#instant"><a href="#instant"><code>instant</code></a></a></li>
160161
</ul>
161162
<h2><a name="wasi_clocks_timezone_0_2_0"></a>Import interface wasi:clocks/[email protected]</h2>
162163
<hr />
163164
<h3>Types</h3>
164-
<h4><a name="datetime"></a><code>type datetime</code></h4>
165-
<p><a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></p>
165+
<h4><a name="instant"></a><code>type instant</code></h4>
166+
<p><a href="#instant"><a href="#instant"><code>instant</code></a></a></p>
166167
<p>
167168
#### <a name="timezone_display"></a>`record timezone-display`
168-
<p>Information useful for displaying the timezone of a specific <a href="#datetime"><code>datetime</code></a>.</p>
169+
<p>Information useful for displaying a specific <a href="#instant"><code>instant</code></a> in the currently
170+
configured time zone.</p>
169171
<p>This information may vary within a single <code>timezone</code> to reflect daylight
170172
saving time adjustments.</p>
171173
<h5>Record Fields</h5>
@@ -199,15 +201,15 @@ should return false.</p>
199201
<hr />
200202
<h3>Functions</h3>
201203
<h4><a name="display"></a><code>display: func</code></h4>
202-
<p>Return information needed to display the given <a href="#datetime"><code>datetime</code></a>. This includes
203-
the UTC offset, the time zone name, and a flag indicating whether
204-
daylight saving time is active.</p>
205-
<p>If the timezone cannot be determined for the given <a href="#datetime"><code>datetime</code></a>, return a
204+
<p>Return information needed to display the given <a href="#instant"><code>instant</code></a> in the
205+
currently configured time zone. This includes the UTC offset, the time
206+
zone name, and a flag indicating whether daylight saving time is active.</p>
207+
<p>If the currently configured timezone cannot be determined, return a
206208
<a href="#timezone_display"><code>timezone-display</code></a> for <code>UTC</code> with a <a href="#utc_offset"><code>utc-offset</code></a> of 0 and no daylight
207209
saving time.</p>
208210
<h5>Params</h5>
209211
<ul>
210-
<li><a name="display.when"></a><code>when</code>: <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
212+
<li><a name="display.when"></a><code>when</code>: <a href="#instant"><a href="#instant"><code>instant</code></a></a></li>
211213
</ul>
212214
<h5>Return values</h5>
213215
<ul>
@@ -217,7 +219,7 @@ saving time.</p>
217219
<p>The same as <a href="#display"><code>display</code></a>, but only return the UTC offset.</p>
218220
<h5>Params</h5>
219221
<ul>
220-
<li><a name="utc_offset.when"></a><code>when</code>: <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
222+
<li><a name="utc_offset.when"></a><code>when</code>: <a href="#instant"><a href="#instant"><code>instant</code></a></a></li>
221223
</ul>
222224
<h5>Return values</h5>
223225
<ul>

wit/system-clock.wit

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@ package wasi:[email protected];
55
/// It is intended to be portable at least between Unix-family platforms and
66
/// Windows.
77
///
8-
/// A wall clock is a clock which measures the date and time according to
9-
/// some external reference.
8+
/// An "instant", or "exact time", is a point in time without regard to any time
9+
/// zone: just the time since a particular external reference point, often
10+
/// called an "epoch".
1011
///
1112
/// External references may be reset, so this clock is not necessarily
1213
/// monotonic, making it unsuitable for measuring elapsed time.
1314
///
1415
/// It is intended for reporting the current date and time for humans.
1516
@since(version = 0.2.0)
1617
interface system-clock {
17-
/// A time and date in seconds plus nanoseconds.
18+
/// An exact time in seconds plus nanoseconds.
1819
@since(version = 0.2.0)
19-
record datetime {
20+
record instant {
2021
seconds: u64,
2122
nanoseconds: u32,
2223
}
@@ -35,11 +36,14 @@ interface system-clock {
3536
/// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
3637
/// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
3738
@since(version = 0.2.0)
38-
now: func() -> datetime;
39+
now: func() -> instant;
3940

4041
/// Query the resolution of the clock.
4142
///
4243
/// The nanoseconds field of the output is always less than 1000000000.
4344
@since(version = 0.2.0)
44-
resolution: func() -> datetime;
45+
resolution: func() -> instant;
46+
// NOTE: This return value doesn't represent an exact time, so maybe is not
47+
// a correct use of the Instant type. Would it make sense to have a
48+
// system-clock::duration analogous to monotonic-clock::duration?
4549
}

wit/timezone.wit

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@ package wasi:[email protected];
33
@unstable(feature = clocks-timezone)
44
interface timezone {
55
@unstable(feature = clocks-timezone)
6-
use system-clock.{datetime};
6+
use system-clock.{instant};
77

8-
/// Return information needed to display the given `datetime`. This includes
9-
/// the UTC offset, the time zone name, and a flag indicating whether
10-
/// daylight saving time is active.
8+
/// Return information needed to display the given `instant` in the
9+
/// currently configured time zone. This includes the UTC offset, the time
10+
/// zone name, and a flag indicating whether daylight saving time is active.
1111
///
12-
/// If the timezone cannot be determined for the given `datetime`, return a
12+
/// If the currently configured timezone cannot be determined, return a
1313
/// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight
1414
/// saving time.
1515
@unstable(feature = clocks-timezone)
16-
display: func(when: datetime) -> timezone-display;
16+
display: func(when: instant) -> timezone-display;
1717

1818
/// The same as `display`, but only return the UTC offset.
1919
@unstable(feature = clocks-timezone)
20-
utc-offset: func(when: datetime) -> s32;
20+
utc-offset: func(when: instant) -> s32;
2121

22-
/// Information useful for displaying the timezone of a specific `datetime`.
22+
/// Information useful for displaying a specific `instant` in the currently
23+
/// configured time zone.
2324
///
2425
/// This information may vary within a single `timezone` to reflect daylight
2526
/// saving time adjustments.

0 commit comments

Comments
 (0)