18 releases

0.6.18 Nov 27, 2023
0.6.15 Jun 14, 2023
0.6.4 Aug 12, 2022
0.5.6 Aug 12, 2022

#242 in Date and time

Download history 70/week @ 2023-12-18 15/week @ 2023-12-25 30/week @ 2024-01-15 74/week @ 2024-01-22 109/week @ 2024-01-29 317/week @ 2024-02-05 112/week @ 2024-02-12 250/week @ 2024-02-19 154/week @ 2024-02-26 95/week @ 2024-03-04 119/week @ 2024-03-11 15/week @ 2024-03-18 7/week @ 2024-03-25 149/week @ 2024-04-01

297 downloads per month
Used in opening-hours

MIT/Apache

27KB
266 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