A simple crate to keep track of holidays each year in sweden.
Getting the date of a Holiday in a given year:
use holidays_se::Holiday;
assert_eq!(Holiday::Paskdagen.in_year(2020), Stockholm.ymd(2020, 4, 12));
A more useful case might be to partition a given time range into slices depending on the kind of day: ```
use chrono::TimeZone; use chrono_tz::Europe::Stockholm;
let start = Stockholm.ymd(2020, 9, 18).andhms(0, 0, 0); // Friday let end = Stockholm.ymd(2020, 9, 21).andhms(13, 15, 0); // Monday at 13:15
let mut iter = holidaysse::sliceondaykind(start..end);
asserteq!( Some(DayKindSlice { range: start.naivelocal() ..Stockholm.ymd(2020, 9, 19).andhms(0, 0, 0).naivelocal(), kind: DayKind::Weekday, }), iter.next(), "First slice should be the whole of Friday" );
asserteq!( Some(DayKindSlice { range: Stockholm.ymd(2020, 9, 19).andhms(0, 0, 0).naivelocal() ..Stockholm.ymd(2020, 9, 20).andhms(0, 0, 0).naive_local(), kind: DayKind::DayBeforeHoliday, }), iter.next(), "Second slice should be the whole of Saturday" );
asserteq!( Some(DayKindSlice { range: Stockholm.ymd(2020, 9, 20).andhms(0, 0, 0).naivelocal() ..Stockholm.ymd(2020, 9, 21).andhms(0, 0, 0).naive_local(), kind: DayKind::Holiday, }), iter.next(), "Third slice should be the whole of Sunday" );
asserteq!( Some(DayKindSlice { range: Stockholm.ymd(2020, 9, 21).andhms(0, 0, 0).naivelocal() ..Stockholm.ymd(2020, 9, 21).andhms(13, 15, 0).naive_local(), kind: DayKind::Weekday, }), iter.next(), "Fourth slice should be Monday until 13:15" );
assert!( iter.next().is_none(), "Iterator should be empty after monday" );
```