Get holidays in Japan.
[dependencies]
holiday_jp = { git = "https://github.com/holiday-jp/holiday_jp-rust", tag = "0.3.0" }
time = "0.3.28"
Already holiday_jp crate was reserved. We need to specify github repository for now.
use holiday_jp::HolidayJp;
use time::{Date, Month};
fn main() {
let from_date = Date::from_calendar_date(2010, Month::September, 14).unwrap();
let to_date = Date::from_calendar_date(2010, Month::September, 21).unwrap();
let holidays = HolidayJp::between(from_date, to_date);
println!("{}", holidays.first().unwrap().name); // 敬老の日
let date = Date::from_calendar_date(2016, Month::August, 11).unwrap();
println!("{}", HolidayJp::is_holiday(date)); // true
}
See examples/basic.rs
and run it with cargo run --example basic
.
Difference of original holiday_jp crate
- Original crate fetchs holidays from Google Calendar. This crate fetchs holidays from Yaml file. It uses Japanese holiday datasets.
- Original crate returns
true
if Saturday and Sunday. This crate returnsfalse
. - This crate has
HolidayJp::is_holiday
andHolidayJp::between
methods. Those are same method names with holiday-jp_ruby.