10 releases (1 stable)

1.0.1 May 14, 2024
0.1.8 Apr 17, 2024
0.1.2 Mar 28, 2024

#243 in Date and time

Download history 484/week @ 2024-07-27 152/week @ 2024-08-03 287/week @ 2024-08-10 124/week @ 2024-08-17 169/week @ 2024-08-24 201/week @ 2024-08-31 239/week @ 2024-09-07 37/week @ 2024-09-14 96/week @ 2024-09-21 68/week @ 2024-09-28 134/week @ 2024-10-05 128/week @ 2024-10-12 14/week @ 2024-10-19 17/week @ 2024-10-26 16/week @ 2024-11-02 19/week @ 2024-11-09

101 downloads per month
Used in datetime-rs

MIT license

46KB
986 lines

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.
  • easter: Enables calculation for the date of Easter.
  • serde: Enables serialization and desearialization with serde. (Enabled by default.)
  • tz: Enables support for time-zone-aware date construction.

Dependencies

~0.1–1.3MB
~26K SLoC