24 unstable releases (4 breaking)

new 0.9.0 Nov 19, 2024
0.8.3 Nov 17, 2024
0.8.2 Oct 30, 2024
0.7.0 Oct 28, 2024
0.5.6 Aug 12, 2022

#270 in Date and time

Download history 31/week @ 2024-07-30 43/week @ 2024-08-06 32/week @ 2024-08-13 38/week @ 2024-08-20 88/week @ 2024-08-27 59/week @ 2024-09-03 142/week @ 2024-09-10 120/week @ 2024-09-17 109/week @ 2024-09-24 165/week @ 2024-10-01 140/week @ 2024-10-08 91/week @ 2024-10-15 182/week @ 2024-10-22 589/week @ 2024-10-29 208/week @ 2024-11-05 308/week @ 2024-11-12

1,320 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