@@ -6,8 +6,8 @@ authors: boa-dev
66
77This will be a series of posts primarily about implementing a new
88JavaScript 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
1212Why should you care? Well we are not only implementing it for
1313JavaScript, but Rust as well ... more on that in a bit.
@@ -54,19 +54,19 @@ few things became evident.
5454
5555So after the prototype was merged, the prototype was pulled out of Boa's
5656internal 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
5858experimental flag in Boa v0.18.
5959
6060After over a year and a half of development, Boa now sits at about 90%
6161overall conformance for Temporal and growing with the entire
6262implementation 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
6565library that can be used to implement temporal in a JavaScript engine or
6666for general usage purposes.
6767
6868So 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
7070specification.
7171
7272## Important core differences
@@ -82,7 +82,7 @@ is not ideal for implementing deep language specifications where an
8282object or string may need to be cloned. Furthermore, it's just not great
8383for 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
8686primitive to handle casting and constraining, respectively, to adapt
8787values 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
109109be going over below.
110110
111111## Implementing constructors
@@ -158,14 +158,14 @@ let plain_date = PlainDate::try_new(2025, 6, 9, Calendar::default())?;
158158```
159159
160160We 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
1631631 . Temporal.PlainDate constructor can throw.
1641642 . When the calendar is omitted, the default calendar is used (this will
165165 default to the ` iso8601 ` calendar)
166166
167167Of 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
169169additional constructors ` new_iso ` and ` try_new_iso ` .
170170
171171## Let's discuss Now
@@ -213,7 +213,7 @@ invoking the abstract operations: `SystemTimeZoneIdentifier` and
213213suspects ` SystemTime ` and ` iana-time-zone ` , merge it, and call it a day
214214on 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
217217engine implementation, accessing a system clock and system time zone are
218218not in scope and must be left up to the engine or runtime to provide
219219that functionality.
@@ -277,7 +277,7 @@ for you!
277277
278278Simple, 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
281281that! ... At least in one method.
282282
283283Again, 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
320320components ` from_partial ` method.
321321
322322With 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 };
326328let pdt = PlainDateTime :: try_new_iso (2025 , 1 , 1 )? ;
327329// We can use the `PlainDateTime` (`ZonedDateTime` / `PlainDate` are also options).
328330let pd_from_pdt = PlainDate :: from (pdt );
@@ -349,21 +351,31 @@ interesting and everyone totally 100% loves them. No, time zones aren't
349351in this post, because they are still being polished and deserve an
350352entire 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
354362In conclusion, we're implementing Temporal in Rust to support engine
355363implementors as well as to have the API available in native Rust in
356364general.
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%
360368conformant before the end of the year.
361369
362370If you're interested in trying Temporal using Boa, you can use it in
363371Boa'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+
365377If 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
369381cargo add temporal_rs
@@ -394,8 +406,8 @@ the API.
3944063 . Partial objects may need some adjustments to handle differences
395407 between ` from_partial ` and ` with `
3964084 . 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! )
3994115 . 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