Skip to content

Commit cb09862

Browse files
committed
Some small adjustments and cleanup
1 parent e72ed83 commit cb09862

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

blog/temporal-introduction.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ authors: boa-dev
66

77
This will be a series of posts primarily about implementing a new
88
JavaScript feature in Rust, specifically the new date/time builtin:
9-
Temporal. We'll go over general lessons and to discuss the library we've
10-
been working on.
9+
Temporal. We'll be going over the general implementation of Temporal in
10+
Boa as well as the crates supporting that implementation.
1111

1212
Why should you care? Well we are not only implementing it for
1313
JavaScript, but Rust as well ... more on that in a bit.
@@ -54,19 +54,19 @@ few things became evident.
5454

5555
So after the prototype was merged, the prototype was pulled out of Boa's
5656
internal builtins and externalized into its own crate,
57-
[temporal_rs][temporal-rs-repo], which then first landed behind an
57+
[`temporal_rs`][temporal-rs-repo], which then first landed behind an
5858
experimental flag in Boa v0.18.
5959

6060
After over a year and a half of development, Boa now sits at about 90%
6161
overall conformance for Temporal and growing with the entire
6262
implementation backed by `temporal_rs`.
6363

64-
For its part, `temporal_rs` is shaping out to be a proper Rust date/time
64+
For its part, `temporal_rs` is shaping up to be a proper Rust date/time
6565
library that can be used to implement temporal in a JavaScript engine or
6666
for general usage purposes.
6767

6868
So let's take a look at Temporal: it's JavaScript API, it's Rust API in
69-
temporal_rs, and how temporal_rs supports implementing the
69+
`temporal_rs`, and how `temporal_rs` supports implementing the
7070
specification.
7171

7272
## Important core differences
@@ -82,7 +82,7 @@ is not ideal for implementing deep language specifications where an
8282
object or string may need to be cloned. Furthermore, it's just not great
8383
for an API in a typed language like Rust.
8484

85-
To work around this, we use liberally `FromStr` and a `FiniteF64` custom
85+
To work around this, we routinely use `FromStr` and a `FiniteF64` custom
8686
primitive to handle casting and constraining, respectively, to adapt
8787
values for use with a typed API.
8888

@@ -105,7 +105,7 @@ let overflow: Option<ArithmeticOverflow> = get_option::<ArithmeticOverflow>(
105105
)?;
106106
```
107107

108-
This is the core glue between Boa and the temporal_rs API that we will
108+
This is the core glue between Boa and the `temporal_rs` API that we will
109109
be going over below.
110110

111111
## Implementing constructors
@@ -158,14 +158,14 @@ let plain_date = PlainDate::try_new(2025, 6, 9, Calendar::default())?;
158158
```
159159

160160
We actually learn some interesting things immediately about the
161-
JavaScript API from looking at the temporal_rs API:
161+
JavaScript API from looking at the `temporal_rs` API:
162162

163163
1. Temporal.PlainDate constructor can throw.
164164
2. When the calendar is omitted, the default calendar is used (this will
165165
default to the `iso8601` calendar)
166166

167167
Of course, if you somewhat prefer the brevity of the JavaScript API and
168-
don't want to list the default Calendar, temporal_rs provides the
168+
don't want to list the default Calendar, `temporal_rs` provides the
169169
additional constructors `new_iso` and `try_new_iso`.
170170

171171
## Let's discuss Now
@@ -213,7 +213,7 @@ invoking the abstract operations: `SystemTimeZoneIdentifier` and
213213
suspects `SystemTime` and `iana-time-zone`, merge it, and call it a day
214214
on the implementation, right?
215215

216-
Except the core purpose of temporal_rs is that it can be used in any
216+
Except the core purpose of `temporal_rs` is that it can be used in any
217217
engine implementation, accessing a system clock and system time zone are
218218
not in scope and must be left up to the engine or runtime to provide
219219
that functionality.
@@ -277,7 +277,7 @@ for you!
277277

278278
Simple, right?
279279

280-
Well we're pleased to announce that temporal_rs won't be supporting
280+
Well we're pleased to announce that `temporal_rs` won't be supporting
281281
that! ... At least in one method.
282282

283283
Again, the goal of `temporal_rs` is to implement the specification to
@@ -320,9 +320,11 @@ exists for each of the components that can then be provided to that
320320
components `from_partial` method.
321321

322322
With this, we have fully implemented support for the `from` method in
323-
`temporal_rs`
323+
`temporal_rs`:
324324

325325
```rust
326+
use core::str::FromStr;
327+
use temporal_rs::{PlainDate, PlainDateTime, partial::PartialDate};
326328
let pdt = PlainDateTime::try_new_iso(2025, 1, 1)?;
327329
// We can use the `PlainDateTime` (`ZonedDateTime` / `PlainDate` are also options).
328330
let pd_from_pdt = PlainDate::from(pdt);
@@ -349,21 +351,31 @@ interesting and everyone totally 100% loves them. No, time zones aren't
349351
in this post, because they are still being polished and deserve an
350352
entire post of their own.
351353

354+
So stay tuned for our next post on implementing Temporal! The one where
355+
we'll hopefully go over everyone's favorite subject, time zones; and
356+
answer the question that some of you may have if you happen to take a
357+
glance at `temporal_rs`'s docs or try out our `no_std` support: what in
358+
the world is a provider API?
359+
352360
## Conclusion
353361

354362
In conclusion, we're implementing Temporal in Rust to support engine
355363
implementors as well as to have the API available in native Rust in
356364
general.
357365

358-
Boa currently sit at a [90% conformance rate][boa-test262] for Temporal
359-
completely backed by temporal_rs v0.0.8, and we're aiming to be 100%
366+
Boa currently sits at a [90% conformance rate][boa-test262] for Temporal
367+
completely backed by `temporal_rs` v0.0.8, and we're aiming to be 100%
360368
conformant before the end of the year.
361369

362370
If you're interested in trying Temporal using Boa, you can use it in
363371
Boa's CLI or enable it in `boa_engine` with the `experimental` flag.
364372

373+
Outside of Boa's implementation, `temporal_rs` has implemented or
374+
supports the implementation for a large portion of the Temporal's API in
375+
native Rust.
376+
365377
If you're interested in trying out `temporal_rs`, feel free to add to
366-
your project with cargo:
378+
your project with Cargo:
367379

368380
```bash
369381
cargo add temporal_rs
@@ -394,8 +406,8 @@ the API.
394406
3. Partial objects may need some adjustments to handle differences
395407
between `from_partial` and `with`
396408
4. Time zone provider's and the `TimeZoneProvider` trait are still
397-
largely unstable (although the APIs that use them are expected to be
398-
stable)
409+
largely unstable. Although, the provider APIs that use them are
410+
expected to be stable (spoilers!)
399411
5. Era and month code are still be discussed in the intl-era-month-code
400412
proposal, so some calendars and calendar methods may have varying
401413
levels of support.

0 commit comments

Comments
 (0)