Skip to content

Commit 3b4af71

Browse files
lutzkydjc
authored andcommitted
Add warning about MappedLocalTime and wasm
Warns about #1701.
1 parent c5c22a3 commit 3b4af71

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/offset/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ pub use self::utc::Utc;
4646
/// DST.
4747
/// * No result when the clock is turned forwards during a transition due to for example DST.
4848
///
49+
/// <div class="warning">
50+
///
51+
/// In wasm, when using [`Local`], only the [`LocalResult::Single`] variant is returned.
52+
/// Specifically:
53+
///
54+
/// * When the clock is turned backwards, where `Ambiguous(earliest, latest)` would be expected,
55+
/// `Single(earliest)` is returned instead.
56+
/// * When the clock is turned forwards, where `None` would be expected, `Single(t)` is returned,
57+
/// with `t` being the requested local time represented as though there is no transition on that
58+
/// day (i.e. still "summer time")
59+
///
60+
/// This is caused because of limitations in the JavaScript
61+
/// [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
62+
/// API, which always parses a local time as a single, valid time - even for an
63+
/// input which describes a nonexistent or ambiguous time.
64+
///
65+
/// See further discussion and workarounds in <https://github.com/chronotope/chrono/issues/1701>.
66+
///
67+
/// </div>
68+
///
4969
/// When the clock is turned backwards it creates a _fold_ in local time, during which the local
5070
/// time is _ambiguous_. When the clock is turned forwards it creates a _gap_ in local time, during
5171
/// which the local time is _missing_, or does not exist.

0 commit comments

Comments
 (0)