Skip to main content

A study in minimalism: date

There are three use cases for dates in Writestreak: post date, comment date and notification date. The first question I asked from my self was "can I use same format for them all?". For developers perspective the simplest solution would be to display all the dates the same way. This could save some precious lines of code and also make the system less complex and thus easier to maintain. After a careful consideration I decided they have different needs: the post has the date it was posted, anchoring it as a baseline action. Notifications and comments instead are events: something that happened to the post, or triggered by the post e.g. something that happened a certain time ago. So I ended up with two different date formats for three use cases. Not the absolute minimum, but a practical one.

Both formats in turn presented me an another dilemma: for the relative time it was the implementation while for the date it was the actual date format.

I already had the relative format in use for comments and notifications, so I didn't have need to change anything. However the initial solution I used to achieve that format was to use Luxon a JavaScript wrapper for date formatting. While it made using relative time super easy it was overkill for my taste to waste 69kb of bandwidth to deliver such a simple functionality. I removed the Luxon-package, the replacement was 25 lines of custom code. Quite the reduction!

But that was easy, a technical problem with explicit solution. The date format however...

The datetime is already a huge trouble from technical perspective with all it's variations and nuances, but it's also hard to display it so that its clear to everyone what date we are talking about. For example writing today's date 9/2/2021 can confuse a lot of people. We are not yet in September! Also should I use "/" or "." or something else to separate the days, months and years? The minimal approach would be to use spaces, they kinda don't count and it would mean I would only need to use characters from one set (numbers, letters, special characters). But 9 2 2021 looks a bit weird. However combined with my solution with the ambiguity problem it can work nicely. So next, to ensure the date is not ambiguous, I needed to make sure the month and the day can't be mixed up. I believe the simplest solution to this is to display the month written out (or in short form) e.g. 9 Feb 2021. Cant it get any more clean than that? Sure the year could be written shorter as -21, but again considering losing only one character but increasing the character types by 50% doesn't sound minimalistic.