yasumi

Crates.ioyasumi
lib.rsyasumi
version0.2.1
sourcesrc
created_at2024-09-16 12:17:26.50723
updated_at2024-09-17 09:28:45.511617
descriptionYasumi is a library for calculating the dates of Japanese holidays.
homepagehttps://github.com/telumo/yasumi-rs
repositoryhttps://github.com/telumo/yasumi-rs
max_upload_size
id1376276
size78,045
Hikaru Hasegawa (telumo)

documentation

https://docs.rs/yasumi

README

🎌 Yasumi - Japanese Holidays for Rust

Yasumi is a Rust library inspired by the popular jpholiday Python package. It allows you to determine whether a given date is a holiday in Japan and retrieve holiday lists for specific years.

With Yasumi, you get an ergonomic, high-performance Rust library for managing Japanese holidays, while maintaining the familiar interface of jpholiday.

πŸš€ Features

  • 🌸 Determine if a date is a Japanese holiday.
  • 🎏 Retrieve the name of the holiday on a specific date.
  • πŸ“… Fetch a list of holidays for any given month or year.

πŸ”§ Installation

To include Yasumi in your Rust project, add the following to your Cargo.toml:

[dependencies]
yasumi = "0.1.0"

Then build your project with:

cargo build

πŸ“– Usage

Here’s a quick example to get started with Yasumi:

use yasumi::{is_holiday, holiday_name, year_holidays};

fn main() {
    let date = "2024-01-01";

    if let Some(holiday) = holiday_name(date) {
        println!("{} is a holiday: {}", date, holiday);
    } else {
        println!("{} is not a holiday.", date);
    }

    let holidays = year_holidays(2024);
    for (date, name) in holidays {
        println!("Holiday on {}: {}", date, name);
    }
}

Available Functions

  • is_holiday_name<T: DateLike>(date: T) -> Option Check if the given date is a holiday and get its name, if available.
  • holiday_name<T: DateLike>(date: T) -> Option Get the name of the holiday on the given date, if it’s a holiday.
  • is_holiday<T: DateLike>(date: T) -> bool Check if the given date is a holiday.
  • is_no_workday<T: DateLike>(date: T) -> bool Determine if the given date is a non-working day (including holidays, Saturday and Sunday).
  • month_holidays(year: i32, month: u32) -> Vec<(NaiveDate, String)> Get a list of holidays for a specific month in a given year.
  • year_holidays(year: i32) -> Vec<(NaiveDate, String)> Get a list of all holidays in a given year.
  • holidays<T: DateLike>(start_date: T, end_date: T) -> Vec<(NaiveDate, String)> Get a list of holidays between the specified start and end dates.
  • between<T: DateLike>(start_date: T, end_date: T) -> Vec<(NaiveDate, String)> Same as holidays.

πŸ’‘ Why Rust?

Rust is known for its memory safety, speed, and concurrency support. Yasumi leverages Rust’s strengths to provide a high-performance alternative to jpholiday. You get the reliability of Rust with the simplicity of a familiar API.

πŸ›  Development

Clone the repository and build the project:

git clone https://github.com/telumo/yasumi.git
cd yasumi
cargo build

To run tests:

cargo test

πŸŽ‰ Credits

Yasumi is inspired by the jpholiday Python package. Special thanks to the jpholiday community and all contributors who made this project possible.

Commit count: 0

cargo fmt