Skip to content

Commit 3e6bf23

Browse files
committed
A couple edits to the constructor section
1 parent 409f3a4 commit 3e6bf23

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

blog/2025-06-15-temporal-impl-1.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,19 @@ impl PlainDate {
150150
}
151151
```
152152

153-
These methods are flexible enough and allow full coverage of the
154-
Temporal specification.
153+
These three constructors, `new_with_overflow`, `try_new`, and `new`, are
154+
fairly flexible and provide full coverage of the Temporal specification.
155155

156156
For instance, take the below constructor:
157157

158158
```js
159-
const plainDate = Temporal.PlainDate(2025, 6, 9);
159+
const plainDate = new Temporal.PlainDate(2025, 6, 9);
160160
```
161161

162162
Can easily be conveyed in Rust as:
163163

164164
```rust
165+
use temporal_rs::PlainDate;
165166
let plain_date = PlainDate::try_new(2025, 6, 9, Calendar::default())?;
166167
```
167168

@@ -176,6 +177,16 @@ Of course, if you somewhat prefer the brevity of the JavaScript API and
176177
don't want to list the default `Calendar`, `temporal_rs` provides the
177178
additional constructors `new_iso` and `try_new_iso`.
178179

180+
```rust
181+
use temporal_rs::PlainDate;
182+
let plain_date = PlainDate::try_new_iso(2025, 6, 9)?;
183+
```
184+
185+
Interestingly enough, the `_iso` constructors are actually extensions of
186+
Temporal specification to provide a similar API in Rust. This is because
187+
the `_iso` constructors are assumed to exist due to resolving an
188+
`undefined` calendar to the default ISO calendar.
189+
179190
## Let's discuss `Now`
180191

181192
> Colonel Sandurz: Now. You're looking at now, sir. Everything that

0 commit comments

Comments
 (0)