| Crates.io | date-formatter |
| lib.rs | date-formatter |
| version | 0.2.1 |
| created_at | 2024-12-29 15:17:55.072988+00 |
| updated_at | 2025-02-11 16:22:50.395174+00 |
| description | A date formatter crate implemented without chrono. |
| homepage | |
| repository | https://github.com/sivanbil/date-formatter |
| max_upload_size | |
| id | 1498273 |
| size | 20,465 |
A simple and lightweight date formatter crate for Rust. This crate provides functions for formatting, parsing, and performing calculations on dates.
Add the following to your Cargo.toml file:
[dependencies]
date-formatter = "0.1.0" # Replace with the latest version
Then, you can use the crate in your code:
use date_formatter::{format_date, parse_date, days_between};
use std::time::SystemTime;
fn main() {
let now = SystemTime::now();
let formatted_date = format_date(now, "%Y-%m-%d");
println!("Today is: {}", formatted_date);
let parsed_date = parse_date("2024-12-29").unwrap();
println!("Parsed date: {:?}", parsed_date);
let yesterday = now - std::time::Duration::from_secs(86400);
let days = days_between(now, yesterday);
println!("Days between now and yesterday: {}", days);
}
%Y: Year, e.g., "2024"%m: Month, e.g., "12"%d: Day, e.g., "29"Contributions are welcome! Feel free to open an issue or submit a pull request.
This crate is licensed under the MIT License.