15 releases (6 stable)

Uses new Rust 2024

1.4.0 May 16, 2025
1.3.0 May 12, 2025
1.2.1 Apr 29, 2025
1.2.0 Mar 17, 2025
0.1.2 Mar 28, 2024

#147 in Date and time

Download history 82/week @ 2025-02-12 87/week @ 2025-02-19 213/week @ 2025-02-26 56/week @ 2025-03-05 264/week @ 2025-03-12 205/week @ 2025-03-19 52/week @ 2025-03-26 181/week @ 2025-04-02 42/week @ 2025-04-09 72/week @ 2025-04-16 192/week @ 2025-04-23 283/week @ 2025-04-30 191/week @ 2025-05-07 404/week @ 2025-05-14 34/week @ 2025-05-21 70/week @ 2025-05-28

710 downloads per month
Used in datetime-rs

MIT license

48KB
1K SLoC

Date

ci codecov release docs

The date crate provides a simple, easy-to-use Date struct (and corresponding macro). Date provides storage for a single Gregorian calendar date.

Date can currently represent any valid calendar date between years -32,768 and 32,767.

Examples

Making a date:

use date::Date;

let date = Date::new(2012, 4, 21);

You can also use the date! macro to get a syntax resembling a date literal:

use date::date;

let date = date! { 2012-04-21 };

Overflow

Date provides an overflowing_new function that allows for overflow values (for example, February 30 or December 32), and maps them accordingly. This allows users to perform certain mathematical computations without having to do their own overflow checking.

Features

date-rs ships with the following features:

  • diesel-pg: Enables interop with PostgreSQL DATE columns using Diesel.
  • duckdb: Enables interop with duckdb crate.
  • easter: Enables calculation for the date of Easter (Gregorian calenda).
  • log: Adds log::kv::ToValue implementation.
  • serde: Enables serialization and desearialization with serde. (Enabled by default.)
  • tz: Enables support for time-zone-aware date construction.

Dependencies

~0.1–7MB
~94K SLoC