`Tempus`, the library to handle time slots

Tempus has become more than just plain time slot management. The best example would be managing a schedule for the dentist (check if the slot is available, or joint, or when the next available slot of the given duration is available, etc.)

It allows one to manage time slots effortlessly. The mathematical background of the implementation reveals that under the hood it has an Enumerable which implements a protocol. Two default implementations backed by List and Stream are included.

Adding a slot to an instance of Tempus.Slots automagically merges it if applicable. List implementation (which is the most suitable for short slot series) might be merged into the Stream implementation.

From the outmost world, the usage is as easy as Tempus.free?(slots, origin) or like. Slots obviously implement Collectable protocol and other goodness.


This version comes with a lot of guards that might be used when dealing with datetimes, not only slots.

Comments and criticism are highly appreciated. We have used this library in production to handle weekends/holidays in different countries (which are declared as an infinite stream) for a couple of years already.

15 Likes

Effective today, Tempus supports different calendars.

It’s still very much WIP and there are tweaks and quirks required in config to make it work with a different calendar (because is_coming_before/2 is essentially a macro which is allowed in guards,) but I have tested it and I can claim it’s fully functional even with datetimes given in different calendars, let alone different timezones.

Enjoy.

6 Likes