| Crates.io | joda_rs |
| lib.rs | joda_rs |
| version | 0.2.0 |
| created_at | 2025-10-09 00:59:50.115344+00 |
| updated_at | 2026-01-19 14:01:16.507686+00 |
| description | A java time / joda like wrapper around the time crate |
| homepage | |
| repository | https://github.com/jstano/joda-rs |
| max_upload_size | |
| id | 1874783 |
| size | 420,585 |
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.
joda_rsLocalDate::of(yyyy, mm, dd) and LocalTime::of(h, m, s).LocalDate::now(), LocalDateTime::now(), ZonedDateTime::now_utc(), and Clock utilities.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.
Add to your Cargo.toml:
[dependencies]
joda_rs = "^0.1.1"
The crate enables useful features on time and time-tz (parsing, local-offset, tz database) by default via its own dependencies.
use joda_rs::{LocalDate, LocalTime, LocalDateTime, OffsetDateTime, ZonedDateTime};
use joda_rs::{ZoneId, ZoneOffset, Duration, Period, ChronoUnit};
fn main() {
// Construct dates and times
let d = LocalDate::of(2025, 9, 15);
let t = LocalTime::of(13, 37, 42);
let ldt = LocalDateTime::of(2025, 9, 15, 13, 37, 42);
// Start of day and combining date/time
let midnight = d.at_start_of_day();
let at_time = d.at_time(t);
// Offsets and zones
let utc = ZoneOffset::of_hours(0);
let odt = OffsetDateTime::of(ldt, utc);
let zdt = ZonedDateTime::of(ldt, ZoneId::UTC);
// Now helpers
let today = LocalDate::now();
let now_local = LocalDateTime::now();
let now_utc_zdt = ZonedDateTime::now_utc();
// Periods and durations
let p = Period::of(1, 2, 3); // 1 year, 2 months, 3 days
let five_sec = Duration::of_seconds(5);
// Arithmetic (java.time-like semantics)
let end_jan = LocalDate::of(2020, 1, 31);
let feb_end = end_jan.plus_months(1); // -> 2020-02-29 (clamped)
// ChronoUnit usage example (between, add)
let added = ChronoUnit::Days.add_to(d, 10); // 2025-09-25
let between_days = ChronoUnit::Days.between(d, added);
// Queries
let dow = d.day_of_week(); // Monday..Sunday
let mon = d.month(); // Month enum
// Parse
let parsed = LocalDate::parse("2025-09-15");
assert_eq!(parsed, d);
// Comparisons
assert!(d.is_on_or_before(added));
assert!(added.is_after(d));
// Use values to avoid warnings
let _ = (midnight, at_time, odt, zdt, today, now_local, now_utc_zdt,
p, five_sec, feb_end, between_days, dow, mon);
}
time crate internally.use statements.Licensed under the Apache License, Version 2.0 (Apache-2.0). See the LICENSE file for details.