Summer's Words

Spec of the Week: Storing Time Makes Me Hate Storing Time

Your mission, should you choose to accept it, is to store a moment in time, which you may not know.

A Short List of Definitions

To hedge my bets against the peanut gallery, the following meanings of common phrases are going to be used for this article.

UTC offset

An offset from UTC time, usually represented as ±[hh]:[mm]

Time zone

This will refer specifically to IANA's time zone database, these look like Australia/Adelaide

Fun fact: That's 2.6MB of data and code so far! 16 copies of Romeo and Juliet! 21 copies of Macbeth!


A Textual representation of a given point in time, or a roughly given point in time, or etc etc.

The Storage of Time: Future Christmas

Our goal will be to refer to 9AM, Christmas morning, that occurs in 2050, currently expected to occur at a regional time of the 25th of December, 2050

So lets go with 2050-12-25T09, nice and easy ISO format. but it leaves a bit to be desired. If I wanted you to celebrate my 9AM Christmas event in the year 2050, We might need to write down something different.

2050-12-25T09+10:30 would probably do the job... If South Australia doesn't abolish daylight savings.

Okay, lets try again, IETF also has had this trouble, and has (not yet) presented Date and Time on the Internet: Timestamps with additional information, so lets look what they suggest.

2050-12-25T09+10:30[!Australia/Adelaide] represents a timestamp that is expected to explode (!) if it becomes inconsistent with its expected occurrence at the time of definition.

But what if Christmas changes? What if I move to a different place in the world? What if I don't move but the time zone moves?

Toto, I have a feeling this won't fit in a single line anymore.

CreationLocation={ lat: -34, long: 138 }

And we still haven't encoded any methods of resolution when invariants break.

The Storage of Time: Contact Book

Some aspects about documentation are fun. Sometimes we want to document what we know, when we don't know much.

My contact book is a great example, people are born, I forget instantly after they tell me their birthdays, people have anniversaries, people have lots of things that are assisted by vaguely correct time keeping.

Introducing the Extended Date/Time Format.

I was born 199X-21-12, Specifically unspecific year, my existence is currently 199X-21-12/.., because I'm (hopefully) not dead while writing this.

I read my vows to my "oshi" on [2021-02-15..2021-02-28] because I only thought about it after Valentines, but before the end of the month.

So on and so fourth. Still, some combinations are a pain: last day of the month would be useful to specify, but while [2021-02-15..2021-02] would encode that, "between the 15th of February, inclusive, and February, inclusive" really burns my brain.

Uncertain and approximate, but not being able to clarify what level of uncertainty or approximity, is another pitfall. Once again, to encode a lot of useful information (especially to nail down the moments of historical events), a lot of bespoke metadata needs to be included.

The Moral of the Story?

You can't win. They couldn't either, that's why features are missing. If you cover every use-case, then you will never finish your work.

So just give up? No! A simple "solution" is possible, just add a notes field to whatever you are making, and people can put notes in. Doesn't solve much, but it could easily solve enough for someone.

All of this is irrelevant to what I want however. I just wanted to send myself a notification on the day before the monthly computer auction, which occurs on the first Friday of each month. I'm so mad at how all cron implementations can't do a "-1 day", like as if humans would never use computers. instead I need to check every Thursday if the day after is a Friday that is within the first 7 days of the month, or I can make it into 2 cron lines or 2 systemd.timer lines, but come on.

And then it hit me: Maybe just exec a binary? Maybe code is the answer? A cron that uses code blobs to determine when things occur might be horrible fun!

Update: It was horrible.