2 releases
0.2.1 | Sep 17, 2024 |
---|---|
0.2.0 | Sep 17, 2024 |
0.1.0 |
|
#57 in Internationalization (i18n)
39 downloads per month
77KB
1.5K
SLoC
π 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.
Dependencies
~2MB
~32K SLoC