#duration #date-time #friendly #utility #chrono

aion

A friendly Rust duration and datetime utility crate

3 unstable releases

0.2.0 Jan 21, 2020
0.1.1 Jan 20, 2020
0.1.0 Jan 19, 2020

#362 in Date and time

Download history 8/week @ 2023-12-31 102/week @ 2024-01-14 49/week @ 2024-01-21 41/week @ 2024-02-04 7/week @ 2024-02-11 90/week @ 2024-02-18 12/week @ 2024-02-25 135/week @ 2024-03-03 137/week @ 2024-03-10 51/week @ 2024-03-17 15/week @ 2024-03-24

339 downloads per month

MIT license

6KB
99 lines

Aion

Aion is a utility crate, inspired by rails, that allows you to write Duration and DateTime in a friendly way:

// Easily represent a chrono::Duration
let two_days = 2.days();
let attention_span = 1.seconds();

// Add or subtract durations from the current time (UTC)
let now = Utc::now();
let three_hours_from_now = now + 3.hours();
let two_hours_from_now = 2.hours().from_now();
let last_week = 7.days().ago(); // or 1.weeks().ago()

// More complex DateTimes can be represented using before() and after() methods
let christmas = Utc.ymd(2020, 12, 25).and_hms(0, 0, 0);
let two_weeks_before_christmas = 2.weeks().before(christmas);
let boxing_day = 1.days().after(christmas);

Installation

Add this to your Cargo.toml file:

[dependencies]
aion = "0.2"

Example

The example is located in example folder. You can run it by using

cargo run --example example

Limitations

Currently this crate only will return DateTime<Utc>.

Acknowledgement

This crate is using chrono. Thanks for this awesome crate.

Dependencies

~1MB
~18K SLoC