Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ jobs:
# Todo: eventually we should check in bindings and test them
- name: FFI tests
run: |
pushd temporal_capi/tests/c && make && popd
pushd temporal_capi/tests/cpp && make && popd
pushd crates/temporal_capi/tests/c && make && popd
pushd crates/temporal_capi/tests/cpp && make && popd

- name: temporal_capi tests
run: cargo test -p temporal_capi --all-features
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Also, always feel free to reach out for any advice or feedback as needed.

## Testing and debugging

For more information on testing and debugging `temporal_rs`. Please see
For more information on testing and debugging `temporal`. Please see
the [testing overview](./docs/testing.md).

## Diplomat and `temporal_capi`
Expand Down
35 changes: 21 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 5 additions & 69 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[workspace]
resolver = "2"
members = [
"provider",
"temporal_capi",
"zoneinfo",
"crates/*",

# Tools
"tools/*",
Expand All @@ -12,7 +10,7 @@ members = [
[workspace.package]
edition = "2021"
version = "0.2.6"
rust-version = "1.86.0"
rust-version = "1.95.0"
authors = ["boa-dev"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/boa-dev/temporal"
Expand All @@ -29,9 +27,9 @@ exclude = [

[workspace.dependencies]
# Self
temporal_rs = { version = "0.2.6", path = ".", default-features = false }
timezone_provider = { version = "0.2.6", path = "./provider", default-features = false }
zoneinfo_rs = { version = "0.1.0", path = "./zoneinfo", default-features = false }
temporal = { version = "0.2.6", path = "./crates/temporal", default-features = false }
timezone_provider = { version = "0.2.6", path = "./crates/provider", default-features = false }
zoneinfo_rs = { version = "0.1.0", path = "./crates/zoneinfo", default-features = false }

# Dependencies
rustc-hash = "2.1.0"
Expand Down Expand Up @@ -60,65 +58,3 @@ diplomat-runtime = { version = ">= 0.15.2, < 0.17.0", default-features = false }
diplomat = { version = "0.16.0", default-features = false }


[package]
name = "temporal_rs"
keywords = ["date", "time", "calendar", "timezone", "duration"]
categories = ["date-and-time", "internationalization"]
description = "Temporal in Rust is an implementation of the TC39 Temporal Builtin Proposal in Rust."
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
readme.workspace = true
exclude.workspace = true

[dependencies]

core_maths = "0.1.1"
icu_calendar = { workspace = true, features = ["compiled_data"] }
icu_locale_core.workspace = true
ixdtf = { workspace = true, features = ["duration"] }
num-traits.workspace = true
tinystr.workspace = true
writeable.workspace = true

# log feature
log = { workspace = true, optional = true }

# tzdb feature
timezone_provider = { workspace = true }

# System time feature
web-time = { workspace = true, optional = true }
iana-time-zone = { workspace = true, optional = true }
calendrical_calculations = "0.2.4"

[dev-dependencies]
timezone_provider = { workspace = true, features = ["zoneinfo64", "experimental_tzif"] }
zoneinfo64 = { workspace = true }
resb = "0.1.0"

[features]
default = ["sys-local"]
log = ["dep:log"]
compiled_data = ["tzdb"]
sys = ["std", "compiled_data", "dep:web-time"]
sys-local = ["sys", "dep:iana-time-zone"]
tzdb = [
"std",
"timezone_provider/tzif",
]
std = []
# https://github.com/boa-dev/temporal/issues/613
# ECMA-conformant implementations must store durations as float64-representable numbers
# Rust users probably should not enable this, unless they wish to match the quirks of JavaScript
float64_representable_durations = []

[package.metadata.cargo-all-features]
denylist = ["default"]
max_combination_size = 4

[package.metadata.docs.rs]
all-features = true
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# Temporal in Rust

`temporal_rs` is a Rust date/time library that provides support for calendrical
`temporal` is a Rust date/time library that provides support for calendrical
calculations and time zones that is based on the Temporal specification.

This implementation aims to be 100% test compliant. While initially developed
for [Boa][boa-repo], the crate was split from the engine repository for general
Rust usage and vendoring to other ECMAScript implementations.

For more information on `temporal_rs`'s general position in the Rust date/time
For more information on `temporal`'s general position in the Rust date/time
library ecoystem or whether we may address your use case, see our
[FAQ](./docs/FAQ.md).

Currently, `temporal_rs` is used in Boa, [Kiesel](https://codeberg.org/kiesel-js/kiesel),
Currently, `temporal` is used in Boa, [Kiesel](https://codeberg.org/kiesel-js/kiesel),
and [V8](https://v8.dev) for the core functionality of their Temporal built-ins.

## Project overview

This project publishes the following crates:

- [`temporal_rs`](https://docs.rs/temporal_rs/latest/temporal_rs/), the core date/time library
- [`temporal`](https://docs.rs/temporal/latest/temporal/), the core date/time library
- [`temporal_capi`](https://docs.rs/temporal_capi/latest/temporal_capi/), a FFI crate for C and C++
- [`timezone_provider`](https://docs.rs/timezone_provider/latest/timezone_provider/), a time zone data provider crate
- [`zoneinfo_rs`](https://docs.rs/zoneinfo_rs/latest/zoneinfo_rs/), an experimental zoneinfo compiler crate

## Why use temporal_rs?
## Why use temporal?

Temporal is a date and time library that is both calendar and time zone aware manner. This
means that calendar and time zone support are first class in Temporal.
Expand All @@ -32,7 +32,7 @@ For instance, converting between calendars is as simple as providing the calenda
shown below.

```rust
use temporal_rs::{PlainDate, Calendar};
use temporal::{PlainDate, Calendar};
use tinystr::tinystr;
use core::str::FromStr;

Expand All @@ -46,15 +46,15 @@ assert_eq!(japanese_date.era_year(), Some(7));
assert_eq!(japanese_date.month(), 3)
```

Beyond the general calendar use case, temporal_rs has robust support for
Beyond the general calendar use case, `temporal` has robust support for
time zones which can generally by applied to a `PlainDate` via [`ZonedDateTime`].

**Important Note:** The below API is enabled with the
`compiled_data` feature flag.

```rust
use temporal_rs::{ZonedDateTime, TimeZone};
use temporal_rs::options::{Disambiguation, OffsetDisambiguation};
use temporal::{ZonedDateTime, TimeZone};
use temporal::options::{Disambiguation, OffsetDisambiguation};

let zdt = ZonedDateTime::from_utf8(
b"2025-03-01T11:16:10Z[America/Chicago][u-ca=iso8601]",
Expand Down Expand Up @@ -83,7 +83,7 @@ assert_eq!(zdt_zurich.second(), 10);

## Library Overview

temporal_rs provides 8 core types for working with date and time. The core types are:
`temporal` provides 8 core types for working with date and time. The core types are:

- [PlainDate]
- [PlainTime]
Expand Down Expand Up @@ -117,7 +117,7 @@ time. This can then be used to map to any of the above Temporal types.

```rust
use core::cmp::Ordering;
use temporal_rs::{Temporal, Calendar, ZonedDateTime};
use temporal::{Temporal, Calendar, ZonedDateTime};
let current_instant = Temporal::now().instant().unwrap();
let current_zoned_date_time = Temporal::now().zoned_date_time_iso(None).unwrap();

Expand Down Expand Up @@ -146,19 +146,19 @@ Ordering::Less

## General design

While temporal_rs can be used in native Rust programs, the library is -- first and
While `temporal` can be used in native Rust programs, the library is -- first and
foremost -- designed for use in ECMAScript implementations. This is not to detract
from temporal_rs's use in a native Rust program, but it is important information to
from `temporal`'s use in a native Rust program, but it is important information to
understand in order to understand the library's architecture and general API design.

Without default feature flags, temporal_rs is not released with access to the host
Without default feature flags, `temporal` is not released with access to the host
environment and it does not embed any time zone data. This is important from an
interpreter perspective, because access to the host environment and time zone data
comes from the interpreter's agent, not from a dependency.

Instead, temporal_rs provides the [`HostHooks`][host::HostHooks] and [`TimeZoneProvider`][provider::TimeZoneProvider]
traits that can be implemented and provided as function arguments that temporal_rs will
use to access the host system or time zone data. temporal_rs also provides some baseline
Instead, `temporal` provides the [`HostHooks`][host::HostHooks] and [`TimeZoneProvider`][provider::TimeZoneProvider]
traits that can be implemented and provided as function arguments that `temporal` will
use to access the host system or time zone data. `temporal` also provides some baseline
implementations of the traits that can be selected from depending on application needs.

That being said, this does not mean that everyone must implement their own trait
Expand All @@ -177,7 +177,7 @@ For instance, let's manually write our [`Now`][now::Now] implementation instead
[`Temporal::now()`] with an empty host system implementation.

```rust
use temporal_rs::{Instant, now::Now, host::EmptyHostSystem};
use temporal::{Instant, now::Now, host::EmptyHostSystem};

// The empty host system is a system implementation HostHooks that always
// returns the UNIX_EPOCH and the "+00:00" time zone.
Expand All @@ -193,7 +193,7 @@ However, even in our above example, we cheated a bit. We were still relying on t
but this time without the feature flag.

```rust
use temporal_rs::{Instant, now::Now, host::EmptyHostSystem};
use temporal::{Instant, now::Now, host::EmptyHostSystem};
use timezone_provider::tzif::CompiledTzdbProvider;

let provider = CompiledTzdbProvider::default();
Expand All @@ -209,7 +209,7 @@ assert_eq!(now.instant(), Instant::try_new(0));
```

Now -- pun only partially intended -- we've successfully written a no-default-features
example with temporal_rs!
example with `temporal`!

### What have we learned going over this all this?

Expand All @@ -221,14 +221,14 @@ provides time zone data for you.
Finally, sourcing time zone data is a very scary (but fun!) business. If you're interested
in learning more, feel free to check out the `timezone_provider` crate!

With any luck, this also highlights the general design of temporal_rs. It provides a
With any luck, this also highlights the general design of `temporal`. It provides a
general usage API that aligns with the Temporal specification while also being
flexible enough to provide an power user to take control of their host system access
and time zone data sourcing as needed.

## Formatting

temporal_rs adheres to Temporal grammar, which is a strict version of
`temporal` adheres to Temporal grammar, which is a strict version of
[RFC9557's IXDTF][ixdtf]. RFC9557 is an update to RFC3339 that adds
extensions to the format.

Expand Down Expand Up @@ -269,12 +269,12 @@ information.

<!-- TODO: Potentially update with tests if a runner can be implemented -->

The `temporal_rs`'s current conformance results can be viewed on Boa's
The `temporal`'s current conformance results can be viewed on Boa's
[test262 conformance page](https://boajs.dev/conformance).

## FFI

`temporal_rs` currently has bindings for C++, available via the
`temporal` currently has bindings for C++, available via the
`temporal_capi` crate.

## Communication
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading