I am happy to announce first release of Timere, a time handling and reasoning library, which @Drup and I have been working on recently.
Examples
Christmases which fall on Wednesday from now
let () =
let open Timere in
match
resolve (
after (Date_time.now ())
& months [`Dec]
& days [25]
& weekdays [`Wed]
)
with
| Error msg -> failwith msg
| Ok s ->
Fmt.pr "%a@." (pp_intervals ~sep:(Fmt.any "@.") ()) s
gives
[2024 Dec 25 00:00:00 +00:00:00, 2024 Dec 26 00:00:00 +00:00:00)
[2030 Dec 25 00:00:00 +00:00:00, 2030 Dec 26 00:00:00 +00:00:00)
[2041 Dec 25 00:00:00 +00:00:00, 2041 Dec 26 00:00:00 +00:00:00)
[2047 Dec 25 00:00:00 +00:00:00, 2047 Dec 26 00:00:00 +00:00:00)
[2052 Dec 25 00:00:00 +00:00:00, 2052 Dec 26 00:00:00 +00:00:00)
[2058 Dec 25 00:00:00 +00:00:00, 2058 Dec 26 00:00:00 +00:00:00)
...
See here for more examples
Features
- Timestamp and date time handling with platform independent time zone support
- Subset of the IANA time zone database is built into this library
- Reasoning over time intervals via timere objects/expressions, examples:
- Pattern matching time and intervals. These work across DST boundaries.
- Intersection and union
- Chunking at year or month boundary, or in fixed sizes
- Evaluate (sub)expressions with a different time zone (e.g. intersection of 9am to 5pm of Sydney and 9am to 5pm of New York)