Temporal in Rust
Temporal is a calendar and timezone aware date/time builtin currently proposed for addition to the ECMAScript specification.
temporal_rs is an implementation of Temporal in Rust that aims to be
100% test compliant. While initially developed for Boa, the
crate has been externalized as we intended to make an engine agnostic
and general usage implementation of Temporal and its algorithms.
Example usage
Below are a few examples to give an overview of temporal_rs's current
API.
Convert from an ISO8601 PlainDate into a Japanese PlainDate.
use ;
use tinystr;
use FromStr;
// Create a date with an ISO calendar
let iso8601_date = try_new_iso.unwrap;
// Create a new date with the japanese calendar
let japanese_date = iso8601_date.with_calendar.unwrap;
assert_eq!;
assert_eq!;
assert_eq!
Create a PlainDateTime from a RFC9557 IXDTF string.
For more information on the Internet Extended DateTime Format (IXDTF), see RFC9557.
use PlainDateTime;
use FromStr;
let pdt = from_str.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Create a ZonedDateTime for a RFC9557 IXDTF string.
Important Note: The below API is enabled with the compiled_data feature flag.
use ;
use ;
let zdt = from_str.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
let zurich_zone = try_from_str.unwrap;
let zdt_zurich = zdt.with_timezone.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Temporal proposal
Relevant links and information regarding Temporal can be found below.
Core maintainers
- Jason Williams (jasonwilliams)
- José Julián Espina (jedel1043)
- Kevin Ness (nekevss)
- Boa Developers
Contributing
This project is open source and welcomes anyone interested to participate. Please see CONTRIBUTING.md for more information.
Test262 Conformance
The temporal_rs's current conformance results can be viewed on
Boa's test262 conformance page.
FFI
temporal_rs currently has bindings for C++, available via the
temporal_capi crate.
Communication
Feel free to contact us on Matrix.
License
This project is licensed under the Apache or MIT licenses, at your option.