OCaml date time handling and reasoning library
Note: The project core is largely complete, but still undergoing testing - you're welcome to use it in prototypes, but avoid using it in production for now. The NLP component is WIP.
Disclaimer: Timere is not designed to handle prehistoric events. For prehistoric planning and booking software, please consult appropriate experts.
Christmases which fall on Wednesday from now
let () = let open Timere in match resolve ( after (Date_time.now ()) & months [`Dec] & days  & weekdays [`Wed] ) with | Error msg -> failwith msg | Ok s -> Fmt.pr "%a@." (pp_intervals ~sep:(Fmt.any "@.") ()) s
[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) ...
examples/ for more examples
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
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)
timere-parse if needed) in the
libraries stanza in your dune file
You can optionally pick one of the following two concrete implementations of time zone data source
This is the default implementation which embeds the IANA time zone database from year 1850 to year 2100 exclusive
This embeds no database.
This is suitable for when you want to retrieve time zone data during run time, for instance, to reduce the built artifact size.
The following resources should allow you to implement said approach readily
A usable and test suite covered data source is provided under
List of available time zones is available as
Time_zone.JSON.of_stringcan load files in
You can optionally pick one of the following three concrete implementations of local time zone detection
This is the default implementation which tries to look up info of OS for local time zone name. Should work for common Linux distros.
This simply returns no time zone guesses
This simply returns UTC as the only guess
tzdb-json/ may be useful and usable outside of Timere,
we make no guarantees that the JSON format stays unmodified
(though changes of the format should be a rare occurrence, if ever occurring)
Code files are licensed under the MIT license as specified in the
Time zone database derived files are licensed under its original terms (public domain)
Time zone information is extracted via
zdumpcommand output into
src/time_zone_data.ml, using the IANA database (as time zone files) distributed on Linux
Time zone data handling code copies approach used by chrono-tz
This includes data representation and choices of some algorithms
Local time zone detection approach for
timere.tzlocal.unixbackend is copied from tzlocal
dev & >= "2.5.0"
>= "4.06.1" & < "5.0"