Ten years with the ISO 8601 gem

Published on by Arnau Siches

Ten years ago, I had a need to record information about the duration of my tasks. I was already familiar with the ISO8601 specification to encode dates and times so it felt natural to use the same specification to encode durations in my dataset.

It's never that simple. Although the purpose of the International Organization for Standardization (ISO) is to aim to standardise, without adoption it's merely a specification.

In the case of the ISO8601 entitled “Data elements and interchange formats – Information interchange – Representation of dates and times”, only a subset of the specification is extremely popular. This subset has dedicated profiles such as the famous IETF RFC 3339 but other parts of the specification have a lack of adoption. To my disappointment, the part about encoding durations had little love.

At the time, I was developing mostly in Ruby so I started my journey of making a parser for the ISO8601 duration. My first parser.

I was very fond of regular expressions at the time, and they did serve me well in this case. However, I got carried away and expanded the project from a handful of functions to a proper gem (i.e. a Ruby library) in order to implement the full specification. This goes from dates and times, to durations and recurrent time intervals.

Time went by, and I stopped using Ruby. Also, I gradually reduced my interest in evolving the library. The library had a very mild adoption so I kept updating small bits and bobs over time. Eventually, I asked for volunteers to take over its maintenance but so far no one has stepped up.

Anyway, this is the brief story of a pet project that got me a bit obssessed with how time is represented in computers and how I got more and more horrified with the truth behind time. I recommend reading Time Disorder. and Time on UNIX for a taste.

After 10 years, the ISO8601 specification seems to have more or less the same dysfunctional adoption. The moral of the story is that I haven't changed that much either. Now, I'm in a self-imposed need to have a parser for ISO8601 weeks such as 2020-W30. This time, my language of choice is Rust and the main library for handling dates and times, Chrono, seems to lack precisely what I need. Oh well!