Reputation: 1690
Is there a way to handle date and time, some sort of module, in ocaml ? Vanilla ocaml i mean, so no OPAM, or this kind of things ?
It seems like there is nothing about it on the internet, i would have expected more docs for the OCaml langage, it's so frustrating...
I need it to do operations on date and time, transform date and times into seconds from epoch, and reverse it, ect...
If there is no way i will do my own functions, but if there is something already done in OCaml for that that would be way better !
Upvotes: 4
Views: 5494
Reputation: 35210
OCaml Unix library provides the interface to standard POSIX date/time functions such as time, mktime, gmtime, and localtime. They should be sufficient for your task. See the standard OCaml documentation for futher information.
Also, long time ago I wrote a small library that depends purely on the Unix module, and implements a few useful time transformations. I never published it, but feel free to grab the code, or use it as a set of examples.
And of course, there are plenty of libraries available in OPAM, or via a package manager of your operating system. It is always better, to reuse existing code, rather then duplicate it.
Upvotes: 6