How Long Has It Been?
Dates are ubiquitous in many types of software. They can be used and represented in many different ways, and there are many nuances to exactly how to treat them in different scenarios. Many times we need to represent and compare dates as absolute values. But, in other cases, it is much more friendly for us to format dates in relative terms, like '3 hours ago', or '5 days ago'.
The History of Relative Date Formatting
I was curious about when the 'time ago' type of relative date formatting became popular in software. It has been part of our human concept of time presumably since before the invention of more absolute time concepts. But, when did we start to use them in software?
Here's what the AI says, and as you know, AI is never wrong:
Before the web, relative time in software was uncommon. Things like file modified dates and other event dates were usually represented in absolute terms. In the early 1990s, IRC chat sometimes formatted durations in natural language terms, like idle for 20 minutes and 4 seconds. In the late 1990s, Mac OS 9 and OS X introduced Today and Yesterday groupings in the Finder.
In the early days of the 'Web 2.0' revolution - around 2004 to 2006 - Ruby on Rails made it trivial for programmers to display relative time, and Twitter and Facebook made relative time the norm in activity streams. Other libraries and frameworks, and other apps, followed soon after.
Your Assignment: Write a Relative Time Formatter
Here's an interesting function writing assignment then: write a function that returns a human readable natural language relative time between two dates (or between a date and now).
Read relative time formatter assignment for more details.