Get holidays in Japan.
[dependencies]
holiday_jp = { git = "https://github.com/holiday-jp/holiday_jp-rust", branch = "0.2.0" }
time = "0.2.26
Already holiday_jp crate was reserved. We need to specify github repository for now.
use holiday_jp::HolidayJp;
use time::Date;
fn main() {
let from_date = Date::try_from_ymd(2010, 9, 14).unwrap();
let to_date = Date::try_from_ymd(2010, 9, 21).unwrap();
let holidays = HolidayJp::between(from_date, to_date);
holidays.first().unwrap().name; // 敬老の日
let date = Date::try_from_ymd(2016, 8, 11).unwrap();
HolidayJp::is_holiday(date); // true
}
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.