Expand description
§Easy Time
A simple and intuitive library for handling time in Rust.
easy_time provides a convenient wrapper around chrono to make common time operations
more ergonomic and readable. Calculate dates in the future or past with ease using
human-friendly methods.
§Features
- Simple API for time calculations (seconds, minutes, hours, days, months, years, etc.)
- Support for both local time and UTC
- Generic over any
chronotimezone - Handles edge cases like leap years and month boundaries
- Human-readable method names like
days_from_now()andmonths_ago()
§Quick Start
use easy_time::{EasyTime, TimeUnits};
use chrono::Local;
// Calculate 5 days from now
let future = EasyTime::new(5).days_from_now();
// Calculate 3 months ago
let past = EasyTime::new(3).months_ago();
// Using the convenience methods (specify Local timezone)
let next_week = EasyTime::<Local>::in_future(7, TimeUnits::Days, None);
let last_year = EasyTime::<Local>::in_past(1, TimeUnits::Years, None);§Working with UTC
use easy_time::EasyTime;
// Create an EasyTime instance in UTC
let utc_time = EasyTime::new_with_utc(10);
let ten_hours_later = utc_time.hours_from_now();§Custom Base Time
use easy_time::EasyTime;
use chrono::Local;
// Use a specific starting time instead of "now"
let custom_start = Local::now();
let easy = EasyTime::new_with_local(custom_start, 30);
let thirty_days_later = easy.days_from_now();Structs§
- Easy
Time - The main struct for time operations.
Enums§
- Time
Units - Time units for use with
EasyTime::in_futureandEasyTime::in_pastmethods.
Constants§
- DATE_
FORMAT - Date-only format:
YYYY-MM-DD - DEFAULT_
DATE_ FORMAT - Default date format:
YYYY-MM-DD HH:MM:SS - TIME_
FORMAT - Time-only format:
HH:MM:SS
Traits§
- Easy
Time Ops - Trait for applying time operations in forward or backward directions.