Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's the language agnostic version which you should be able to convert into <em>any</em> language:</p> <pre><code>ONE_MINUTE = 60 ONE_HOUR = 60 * ONE_MINUTE ONE_DAY = 24 * ONE_HOUR ONE_WEEK = 7 * ONE_DAY ONE_MONTH = ONE_DAY * 3652425 / 120000 ONE_YEAR = ONE_DAY * 3652425 / 10000 def when(then): seconds_ago = now() - then if seconds_ago &lt; 0: return "at some point in the future (???)" if seconds_ago == 0: return "now" if seconds_ago == 1: return "1 second ago" if seconds_ago &lt; ONE_MINUTE: return str(seconds_ago) + " seconds ago" if seconds_ago &lt; 2 * ONE_MINUTE: return "1 minute ago" if seconds_ago &lt; ONE_HOUR: return str(seconds_ago/ONE_MINUTE) + " minutes ago" if seconds_ago &lt; 2 * ONE_HOUR: return "1 hour ago" if seconds_ago &lt; ONE_DAY: return str(seconds_ago/ONE_HOUR) + " hours ago" if seconds_ago &lt; 2 * ONE_DAY: return "1 day ago" if seconds_ago &lt; ONE_WEEK: return str(seconds_ago/ONE_DAY) + " days ago" if seconds_ago &lt; 2 * ONE_WEEK: return "1 week ago" if seconds_ago &lt; ONE_MONTH: return str(seconds_ago/ONE_WEEK) + " weeks ago" if seconds_ago &lt; 2 * ONE_MONTH: return "1 month ago" if seconds_ago &lt; ONE_YEAR: return str(seconds_ago/ONE_MONTH) + " months ago" if seconds_ago &lt; 2 * ONE_YEAR: return "1 year ago" return str(seconds_ago/ONE_YEAR) + " years ago" </code></pre> <p>Note that the year/month figures are approximate (based on averages) but that shouldn't really matter since the relative error will still be <em>very</em> low.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload