1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
//! # JPHoliday //! 日本の祝日を取得するライブラリ //! //! ## 指定日の祝日名を取得 //! ```rust //! use jpholiday::jpholiday::JPHoliday; //! use jpholiday::chrono::{NaiveDate}; //! use std::borrow::Borrow; //! //! let jpholiday = JPHoliday::new(); //! //! assert_eq!( //! jpholiday.is_holiday_name(NaiveDate::from_ymd(2017, 1, 1).borrow()).unwrap(), //! "元日".to_string() //! ); //! //! assert_eq!( //! jpholiday.is_holiday_name(NaiveDate::from_ymd(2017, 1, 2).borrow()).unwrap(), //! "元日 振替休日".to_string() //! ); //! //! assert_eq!( //! jpholiday.is_holiday_name(NaiveDate::from_ymd(2017, 1, 3).borrow()), //! None //! ); //! ``` //! //! ## 指定日が祝日か判定 //! ```rust //! use jpholiday::jpholiday::JPHoliday; //! use jpholiday::chrono::{NaiveDate}; //! use std::borrow::Borrow; //! //! let jpholiday = JPHoliday::new(); //! //! assert_eq!( //! jpholiday.is_holiday(NaiveDate::from_ymd(2017, 1, 1).borrow()), //! true //! ); //! //! assert_eq!( //! jpholiday.is_holiday(NaiveDate::from_ymd(2017, 1, 2).borrow()), //! true //! ); //! //! assert_eq!( //! jpholiday.is_holiday(NaiveDate::from_ymd(2017, 1, 3).borrow()), //! false //! ); //! ``` //! //! ## 指定年の祝日を取得 //! ```rust //! use jpholiday::jpholiday::JPHoliday; //! use jpholiday::chrono::{NaiveDate}; //! use std::borrow::Borrow; //! //! let jpholiday = JPHoliday::new(); //! //! assert_eq!( //! jpholiday.year_holidays(2017), //! vec![ //! (NaiveDate::from_ymd(2017, 1, 1), "元日".to_string()), //! (NaiveDate::from_ymd(2017, 1, 2), "元日 振替休日".to_string()), //! (NaiveDate::from_ymd(2017, 1, 9), "成人の日".to_string()), //! (NaiveDate::from_ymd(2017, 2, 11), "建国記念の日".to_string()), //! (NaiveDate::from_ymd(2017, 3, 20), "春分の日".to_string()), //! (NaiveDate::from_ymd(2017, 4, 29), "昭和の日".to_string()), //! (NaiveDate::from_ymd(2017, 5, 3), "憲法記念日".to_string()), //! (NaiveDate::from_ymd(2017, 5, 4), "みどりの日".to_string()), //! (NaiveDate::from_ymd(2017, 5, 5), "こどもの日".to_string()), //! (NaiveDate::from_ymd(2017, 7, 17), "海の日".to_string()), //! (NaiveDate::from_ymd(2017, 8, 11), "山の日".to_string()), //! (NaiveDate::from_ymd(2017, 9, 18), "敬老の日".to_string()), //! (NaiveDate::from_ymd(2017, 9, 23), "秋分の日".to_string()), //! (NaiveDate::from_ymd(2017, 10, 9), "体育の日".to_string()), //! (NaiveDate::from_ymd(2017, 11, 3), "文化の日".to_string()), //! (NaiveDate::from_ymd(2017, 11, 23), "勤労感謝の日".to_string()), //! (NaiveDate::from_ymd(2017, 12, 23), "天皇誕生日".to_string()) //! ] //! ); //! ``` //! //! ## 指定月の祝日を取得 //! ```rust //! use jpholiday::jpholiday::JPHoliday; //! use jpholiday::chrono::{NaiveDate}; //! use std::borrow::Borrow; //! //! let jpholiday = JPHoliday::new(); //! //! assert_eq!( //! jpholiday.month_holidays(2017, 5), //! vec![ //! (NaiveDate::from_ymd(2017, 5, 3), "憲法記念日".to_string()), //! (NaiveDate::from_ymd(2017, 5, 4), "みどりの日".to_string()), //! (NaiveDate::from_ymd(2017, 5, 5), "こどもの日".to_string()) //! ] //! ); //! ``` //! //! ## 指定範囲の祝日を取得 //! ```rust //! use jpholiday::jpholiday::JPHoliday; //! use jpholiday::chrono::{NaiveDate}; //! use std::borrow::Borrow; //! //! let jpholiday = JPHoliday::new(); //! //! assert_eq!( //! jpholiday.between(NaiveDate::from_ymd(2017, 1, 1).borrow(), NaiveDate::from_ymd(2017, 5, 3).borrow()), //! vec![ //! (NaiveDate::from_ymd(2017, 1, 1), "元日".to_string()), //! (NaiveDate::from_ymd(2017, 1, 2), "元日 振替休日".to_string()), //! (NaiveDate::from_ymd(2017, 1, 9), "成人の日".to_string()), //! (NaiveDate::from_ymd(2017, 2, 11), "建国記念の日".to_string()), //! (NaiveDate::from_ymd(2017, 3, 20), "春分の日".to_string()), //! (NaiveDate::from_ymd(2017, 4, 29), "昭和の日".to_string()), //! (NaiveDate::from_ymd(2017, 5, 3), "憲法記念日".to_string()) //! ] //! ); //! ``` //! pub extern crate chrono; pub mod jpholiday; mod holidays; mod registry; mod utils;