# Date parsing and math

**URL:** <https://discuss.ocaml.org/t/date-parsing-and-math/17720>\
**Category:** Community\
**Created:** [January 21, 2026, 12:58am UTC](https://discuss.ocaml.org/t/date-parsing-and-math/17720 "2026-01-21T00:58:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrdn](https://avatars.discourse-cdn.com/v4/letter/j/d9b06d/32.png) [@jrdn](https://discuss.ocaml.org/u/jrdn)\
**Post date:** [January 21, 2026, 12:58am UTC](https://discuss.ocaml.org/t/date-parsing-and-math/17720/1 "2026-01-21T00:58:21Z")

</div>

I’m looking for a date library for parsing/printing, adding offsets (days/months/years/month end flag), and modifying date components. I’m just concerned with dates, not times. Currently using Timedesc.Date, but it only has direct support for adding days. Ideally looking for something analogous to `datetime.date` and `dateutil.relativedelta` in Python world.

Thanks!

---

<div class="post-metadata">

**Author:** ![sanette](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/sanette/32/1645_2.png) [@sanette](https://discuss.ocaml.org/u/sanette)\
**Post date:** [January 21, 2026, 9:35am UTC](https://discuss.ocaml.org/t/date-parsing-and-math/17720/2 "2026-01-21T09:35:47Z")

</div>

`calendar` has everything you want (and more)

> **[calendar 3.0.0 · OCaml Package](https://ocaml.org/p/calendar/latest)**
>
> calendar 3.0.0: Library for handling dates and times in your program

---

<div class="post-metadata">

**Author:** ![louisono](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/louisono/32/6360_2.png) [@louisono](https://discuss.ocaml.org/u/louisono)\
**Post date:** [January 21, 2026, 12:36pm UTC](https://discuss.ocaml.org/t/date-parsing-and-math/17720/3 "2026-01-21T12:36:36Z")

</div>

I have found on opam several packages that might help you. In no particular order:

- calendar, already mentioned by @sanette. Here are the [opam page](https://opam.ocaml.org/packages/calendar/), the [github](https://github.com/ocaml-community/calendar/tree/master), and the [ocaml.org documentation](https://ocaml.org/p/calendar/latest/doc/index.html)
- dates\_calc. Here are the [opam page](https://opam.ocaml.org/packages/dates_calc/), the [github](https://github.com/CatalaLang/dates-calc), and the [ocaml.org documentation](https://ocaml.org/p/dates_calc/latest/doc/index.html)
- odate. Here are the [opam page](https://opam.ocaml.org/packages/odate/), the [github](https://github.com/hhugo/odate), and the [ocaml.org documentation](https://ocaml.org/p/odate/latest/doc/index.html)

Which one you wind up choosing is ultimately up to you but after having a brief look at each I have a few unorganised remarks that may help you in your choice:

- dates\_calc is definitely on the leaner side with a more limited/minimal interface, so it might not be a match for complex requirements. On the other hand it also means the interface is easy to keep in mind.
- odate also includes function for date **& time**. If, as your project evolves, you start needing time support, this might come in handy
- calendar is owned, at least from what I can see on github, by the [ocaml community](https://github.com/ocaml-community) organization and seems to be the most mature of these packages (260+ commits on github vs 50 for odate and 68 for dates\_calc, although number of commits is admittedly not the most reliable metric). The test included in the repository also seems to be the most extensive of these 3 packages

---

<div class="post-metadata">

**Author:** ![jrdn](https://avatars.discourse-cdn.com/v4/letter/j/d9b06d/32.png) [@jrdn](https://discuss.ocaml.org/u/jrdn)\
**Post date:** [January 21, 2026, 12:52pm UTC](https://discuss.ocaml.org/t/date-parsing-and-math/17720/4 "2026-01-21T12:52:18Z")

</div>

> [@sanette](#):
>
> [calendar 3.0.0 (latest) · OCaml Package](https://ocaml.org/p/calendar/latest)

Thanks! I think other than a month end concept (unless I missed it) this matches up.

---

<div class="post-metadata">

**Author:** ![sanette](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/sanette/32/1645_2.png) [@sanette](https://discuss.ocaml.org/u/sanette)\
**Post date:** [January 21, 2026, 9:35pm UTC](https://discuss.ocaml.org/t/date-parsing-and-math/17720/5 "2026-01-21T21:35:47Z")

</div>

> [@jrdn](#):
>
> Thanks! I think other than a month end concept (unless I missed it) this matches up.

I guess you can use `days_in_month` for this

---

<div class="post-metadata">

**Author:** ![jrdn](https://avatars.discourse-cdn.com/v4/letter/j/d9b06d/32.png) [@jrdn](https://discuss.ocaml.org/u/jrdn)\
**Post date:** [January 22, 2026, 12:52am UTC](https://discuss.ocaml.org/t/date-parsing-and-math/17720/6 "2026-01-22T00:52:29Z")

</div>

Yep, will definitely need to handle with care. Looking at the coercion rules again, will need to check against rolling into the next month when adding months as well.
