Skip to content

Commit

Permalink
Make timezone-display::utc-offset in nanoseconds
Browse files Browse the repository at this point in the history
There are time zones that used sub-minute or even sub-second UTC offsets
for instants in the past. E.g., when built using Vanguard format, the UTC
offset in the TZDB for "Asia/Ho_Chi_Minh" before July 1906 is
7:06:30.133333333.
  • Loading branch information
ptomato committed Jul 10, 2024
1 parent f77f01b commit c8c3316
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ saving time adjustments.</p>
<h5>Record Fields</h5>
<ul>
<li>
<p><a name="timezone_display.utc_offset"></a><a href="#utc_offset"><code>utc-offset</code></a>: <code>s32</code></p>
<p>The number of seconds difference between UTC time and the local
<p><a name="timezone_display.utc_offset"></a><a href="#utc_offset"><code>utc-offset</code></a>: <code>s64</code></p>
<p>The number of nanoseconds difference between UTC time and the local
time of the timezone.
<p>The returned value will always be less than 86400 which is the
number of seconds in a day (24<em>60</em>60).</p>
<p>The returned value will always be less than 86,400,000,000,000 which
is the number of nanoseconds in a day (24<em>60</em>60*1e9).</p>
<p>In implementations that do not expose an actual time zone, this
should return 0.</p>
</li>
Expand Down Expand Up @@ -216,5 +216,5 @@ the UTC offset and the time zone name.</p>
</ul>
<h5>Return values</h5>
<ul>
<li><a name="utc_offset.0"></a> <code>s32</code></li>
<li><a name="utc_offset.0"></a> <code>s64</code></li>
</ul>
10 changes: 5 additions & 5 deletions wit/timezone.wit
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ interface timezone {

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

/// Information useful for displaying the timezone of a specific `instant`.
///
/// This information may vary within a single `timezone` to reflect daylight
/// saving time adjustments.
@unstable(feature = clocks-timezone)
record timezone-display {
/// The number of seconds difference between UTC time and the local
/// The number of nanoseconds difference between UTC time and the local
/// time of the timezone.
///
/// The returned value will always be less than 86400 which is the
/// number of seconds in a day (24*60*60).
/// The returned value will always be less than 86,400,000,000,000 which
/// is the number of nanoseconds in a day (24*60*60*1e9).
///
/// In implementations that do not expose an actual time zone, this
/// should return 0.
utc-offset: s32,
utc-offset: s64,

/// The IANA identifier of the timezone. The id `UTC` indicates
/// Coordinated Universal Time. Otherwise, this should be an identifier
Expand Down

0 comments on commit c8c3316

Please sign in to comment.