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 static methods.
§Features
- Simple static 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;
use chrono::Local;
// Calculate 5 days from now
let future = EasyTime::<Local>::days_from_now(5);
// Calculate 3 months ago
let past = EasyTime::<Local>::months_ago(3);
// Using UTC
let utc_future = EasyTime::<Local>::utc_hours_from_now(10);Structs§
- Easy
Time - The main struct for time operations.
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
Functions§
- format_
datetime - Formats a datetime using the default format:
YYYY-MM-DD HH:MM:SS. - format_
datetime_ with - Formats a datetime using a custom format string.
- format_
datetime_ with_ timezone - Formats a datetime with timezone offset appended.
- format_
datetime_ with_ timezone_ format - Formats a datetime with custom format and timezone offset.
- to_date
- Returns just the date portion as
YYYY-MM-DD. - to_time
- Returns just the time portion as
HH:MM:SS. - to_
timestamp - Returns the Unix timestamp (seconds since epoch).