date-formatter

Crates.iodate-formatter
lib.rsdate-formatter
version0.2.1
created_at2024-12-29 15:17:55.072988+00
updated_at2025-02-11 16:22:50.395174+00
descriptionA date formatter crate implemented without chrono.
homepage
repositoryhttps://github.com/sivanbil/date-formatter
max_upload_size
id1498273
size20,465
c-role (sivanbil)

documentation

README

date-formatter

Crates.io Docs.rs

A simple and lightweight date formatter crate for Rust. This crate provides functions for formatting, parsing, and performing calculations on dates.

Features

  • No dependencies: This crate is implemented using only the Rust standard library, so it has no external dependencies.
  • Easy to use: The API is simple and straightforward, making it easy to get started.
  • Lightweight: The crate is small and has minimal overhead.

Usage

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);
}

Supported Formatting Symbols

  • %Y: Year, e.g., "2024"
  • %m: Month, e.g., "12"
  • %d: Day, e.g., "29"

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

This crate is licensed under the MIT License.

Commit count: 6

cargo fmt