Conversation
🦋 Changeset detectedLatest commit: 6cbd973 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
/bonk review this |
|
|
||
| A `Temporal.Instant`, `Temporal.PlainDate`, or `Temporal.Duration` value, respectively. The string is | ||
| the value's `toJSON()` output, an ISO 8601 string, and the receiver reconstructs the value with the | ||
| matching `from()`, e.g. `Temporal.Instant.from(string)`. The encoding is lossless: instants keep |
There was a problem hiding this comment.
The encoding isn't lossless for Temporal.Duration. toJSON() folds sub-second units into the seconds field, so the round trip changes the duration's fields even though the total stays the same. Checked with Node --harmony-temporal:
D.from({milliseconds: 1500}).toJSON() // "PT1.5S"
D.from("PT1.5S") // seconds: 1, milliseconds: 500 (was milliseconds: 1500)
D.from({seconds: 59, milliseconds: 1000}) // -> "PT60S" -> seconds: 60, milliseconds: 0That's a spec limitation of Duration's ISO string form, so the wire format can't avoid it without encoding the fields one by one. Please narrow the claim here (and in the comment at src/serialize.ts:394), for example: "Durations keep their total length, but sub-second units may be rebalanced into seconds." The alternative is a field-wise encoding if callers need exact fields.
|
Review: 1 finding. I posted 1 inline comment on the PR. Ran Node with Not raised inline:
|
No description provided.