[ANN] Timedesc 0.8.0 - modern date time handling

I’m pleased to announce the release of Timedesc 0.8.0.

Timedesc is a very comprehensive date time handling library with good support of time zone.

Homepage

Features

  • Timestamp and date time handling with platform independent time zone support

    • Subset of the IANA time zone database is built into this library
  • Supports Gregorian calendar date, ISO week date, and ISO ordinal date

  • Supports nanosecond precision

  • ISO8601 parsing and RFC3339 printing

Main changes since 0.6.0

  • Significantly reduced size of time zone database by using a custom compression scheme

    • Many thanks to @glennsl for the proposed scheme at issue #46

    • This yields reduction of roughly 82% for same date period. The exact range of years included has been tuned slightly as well and I’ve lost track of the exact size after compilation.

  • Significantly reduced the number of dependencies, and moved JS, JSON code into separate packages

    • Removed dependencies: fmt, containers, oseq

      • Introduced sexplib dependency for sexp handling consequently as previously containers CCSexp was used
    • Moved JSON code into timedesc-json package along with Yojson dependency

    • Moved tzlocal and tzdb stuff into their own separate packages (timedesc-tzlocal and timedesc-tzdb respectively)

    • Moved JS tzlocal backend into timedesc-tzlocal-js (along with JS specific dependencies)

Quality of life changes

  • Updated string conversion functions based on pretty printers which raise Date_time_cannot_deduce_offset_from_utc to raise the exception instead of returning None

    • This simplifies the handling as return type is now simply just string

    • And for serious stuff users are expected to use only unambiguous date times anyway, which would not trigger this exception

  • Added ISO8601 printing facilities to Timestamp module for consistency

    • They are just aliases to the RFC3339 printers
19 Likes

Tiny update: Timedesc 0.9.0 has been released, moving sexplib dependency into timedesc-sexp and moved from mparser to angstrom for some date time text parsers since angstrom is a strict necessity for some binary (de)serialization already.

This overall means Timedesc is about as slim as it can get as a date time handling lib, depending only on: seq, angstrom, result, and ptime (ptime is not a strict dependency, but it’s nice to have timedesc <-> ptime convertors).

2 Likes

Hi,
Is this a lib that targets to process dates and time in a programmatically way?
(this is what the provided example make me think)
Or is it also supposed to be used to print something readable for a user else than a programmer?

If there is no end-user goal in this lib, please just ignore my message, and sorry to make you lose some time.

In the other case if you consider printing for end users, it’s maybe worth to mention that there is the DateLocale-ocaml module that is available and which provides the name for the months, and days for more than 200 languages. It also provides abbreviated versions for both months and days, which are often used.

The ocaml-community/calendar was not designed with localisation in mind, it just does String.sub d 0 3 to provide short names, which will not work with languages that need UTF8.

There is this PR that is still waiting for some review since 2 years to make it compatible with localisation:
ocaml-community/calendar/pull/33.

(At least the patch is available there for someone who could be interested.)

I don’t know if it could interest some one but I see that the example outputs a list of dates, that look like some kind of logs. In case some one would like to visualise it in a way similar than the unix command cal you can just create empty files where the file name follows the pattern YYYY-MM-DD like for example “dir/2022-08-06.txt”, you will then be able to visualise it in the console with detri.

Development has been primarily focused on former, mostly because solving it properly was already (very) involved.

Now that Timedesc has stabilised, the latter reads like a very nice next TODO to match feature parity of other date time libs.

Looks neat! I believe there have been requests of locale sensitive pretty printing/conversion functions, so I definitely would be interested in incorporating your work (if that was the intention).

I was interested in something like this for another small utility cmd I’ve written, neat!