joda-rs
A small, ergonomic wrapper around the Rust time and time-tz crates inspired by Java’s java.time/Joda-Time style API. It provides friendly types like LocalDate, LocalTime, LocalDateTime, OffsetDateTime, ZonedDateTime, Period, Duration, and more, with convenience constructors and methods reminiscent of the Joda/java.time experience.
- Crate:
joda_rs - License: Apache-2.0
- MSRV: same as your toolchain supporting edition 2024 (tested with recent stable)
Features
- Simple constructors like
LocalDate::of(yyyy, mm, dd)andLocalTime::of(h, m, s). - Now/clock helpers:
LocalDate::now(),LocalDateTime::now(),ZonedDateTime::now_utc(), andClockutilities. - Arithmetic and queries: add/subtract days/weeks/months/years, clamp end-of-month behavior like java.time, day-of-week/month helpers, etc.
- Period and Duration types with intuitive constructors.
- Re-exports of the primary types at crate root for easy use:
use joda_rs::{LocalDate, LocalDateTime, ZonedDateTime, ZoneId, ZoneOffset, Duration, Period, ChronoUnit, …};
Under the hood, this crate delegates to the excellent time and time-tz crates.
Installation
Add to your Cargo.toml:
[]
= "^0.1.1"
The crate enables useful features on time and time-tz (parsing, local-offset, tz database) by default via its own dependencies.
Quick start
use ;
use ;
Design notes
- API aims to be convenient and familiar to users of Java’s date/time libraries, while relying on Rust’s
timecrate internally. - Types are re-exported at the crate root for succinct
usestatements. - Some methods intentionally clamp to valid end-of-month values, similar to java.time behavior.
License
Licensed under the Apache License, Version 2.0 (Apache-2.0). See the LICENSE file for details.
Links
- Crate repository: https://github.com/jstano/joda-rs
- Depends on: https://crates.io/crates/time and https://crates.io/crates/time-tz