Crates.io | easy_time |
lib.rs | easy_time |
version | 0.1.5 |
source | src |
created_at | 2023-10-08 19:08:55.325238 |
updated_at | 2024-12-08 19:09:12.159997 |
description | package for handling time in rust more easily |
homepage | |
repository | https://github.com/mohamadzoh/easy_time |
max_upload_size | |
id | 997387 |
size | 31,658 |
The EasyTime library is a Rust crate that provides a simple and flexible way to perform date and time calculations with ease. It leverages the chrono
library to handle date and time manipulations while allowing you to work with various time zones and perform operations like adding or subtracting seconds, minutes, hours, days, months, and years from the current time.
To use the EasyTime library in your Rust project, add it as a dependency in your Cargo.toml
:
[dependencies]
easytime = "0.1.4"
Here's a basic example of how to use the EasyTime library:
extern crate easytime;
use easytime::{EasyTime, Local};
fn main() {
// Create an EasyTime instance with a value of 10 seconds.
let easy_time = EasyTime::new(10);
// Calculate the time 10 seconds from now.
let future_time = easy_time.seconds_from_now();
// Calculate the time 10 seconds ago.
let past_time = easy_time.seconds_ago();
println!("Future Time: {}", future_time);
println!("Past Time: {}", past_time);
}
This example demonstrates how to create an EasyTime instance, add or subtract seconds from the current time, and print the results.
Contributions to the EasyTime library are welcome! Feel free to open issues, submit pull requests, or provide feedback to help improve this library.