Crates.io | date-rs |
lib.rs | date-rs |
version | 1.0.1 |
source | src |
created_at | 2024-03-25 20:49:46.036606 |
updated_at | 2024-05-14 16:21:35.276539 |
description | Gregorian calendar date |
homepage | |
repository | https://github.com/lukesneeringer/date-rs |
max_upload_size | |
id | 1185665 |
size | 49,371 |
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.
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 };
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.
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.