25 unstable releases (4 breaking)

new 0.9.1 Nov 26, 2024
0.8.3 Nov 17, 2024
0.6.18 Nov 27, 2023
0.6.15 Jun 14, 2023
0.6.4 Aug 12, 2022

#207 in Date and time

Download history 40/week @ 2024-08-05 33/week @ 2024-08-12 40/week @ 2024-08-19 71/week @ 2024-08-26 53/week @ 2024-09-02 136/week @ 2024-09-09 130/week @ 2024-09-16 107/week @ 2024-09-23 164/week @ 2024-09-30 144/week @ 2024-10-07 79/week @ 2024-10-14 97/week @ 2024-10-21 678/week @ 2024-10-28 207/week @ 2024-11-04 258/week @ 2024-11-11 380/week @ 2024-11-18

1,524 downloads per month
Used in opening-hours

MIT/Apache

28KB
292 lines

Compact representation for a calendar

This modules basically builds a data-structure for a set of days based on bit-maps. This is built to store a collection of regional holidays for the opening-hours crate.

Data layout

Here is how serialized data is represented:

 start   size       year 1          year 2      ...
┌──────┬──────┬───────────────┬───────────────┬────
│  8B  │  8B  │ 8B * 12 = 96B │ 8B * 12 = 96B │ ...
└──────┴──────┴───────────────┴───────────────┴────

Each year is just an array of 12 u32 where the least significant bits each represent a day.

While a bitset might not be the most efficient way to store a collection of dates for sparse data, this approached proved to be very compact when combined with a Zlib encoder. This methods allowed to store all holidays from 2000 to 2100 as described by workalendar in only 60kb of data.

"Root Package"


"Root Package"


"Documentation"


"Workalendar Python Package"

Dependencies

~1MB
~18K SLoC