iso dates
New "danger smells like clean socks" policy: Technical entries get pictures of beautiful women, like my new celebrity crush, Eva Green. I realized that my entries are boring; I hope pictures of beautiful women can somehow save this awful turd of a journal. I figure this helps you, the reader, in two ways: it will be an immediate prompt to stop wasting time by skipping the entry, and it gives you a chance to admire beautiful women. Who says I don't care about you?!?
. . .
I love human-friendly dates like "two hours ago" or "four weeks ago." It just makes so much more sense than plastering "January 24th, 2008 at 8:45PM." 8:45PM where? Russia? Chapel Hill? San Diego? And when was January 24th? Maybe it's just me, but I can barely remember dates. Human friendly dates provide so much more context ...
Unfortunately, generating human-friendly timestamps on the server side is costly when it comes to caching. Caching (for the non-technically minded) is the act of memorizing data (like webpages) and storing it so that it displays more quickly when requested.
A real-life example of caching, that most of you can relate to, is the multiplication table. What is 12 x 12? Most of you can immediately answer 144, because you memorized it. How many of you got out paper and did it the old-fashioned way? It's the same way with computers: if they can memorize outputs, they can become quicker in processing information. This is especially important when thousands of requests are being sent per hour.
Now, the problem with human-friendly timestamps is that they are dynamic - the computer can never memorize that output. Sure, it can memorize the exact time, but then it must transform that time to a human-friendly format. January 28th, 2008 will always be the same, but it will not be the same relevant to the present (curse the 4th dimension!).
But, a solution appears on the horizon! John Resig, of jQuery fame, wrote up a Javascript library which does it for you! Hooray! This means your server can still cache, and you humans can get your nice human-friendly timestamps. The downside? It's Javascript, so you'll end up with some shifting data onLoad (when it does the content transformation).
I'm also not a huge fan of displaying the ISO time standard, which can look like this: 1997-07-16T19:20:30.45+01:00.
So in implementation, perhaps the best way to approach this is to display a cacheable human-friendly time ("January 8th, 2007 at 8:08 PM") which is surrounded by a span tag which has an overloaded attribute ("title"?) which contains the ISO time. It'd be trivial to hook that pretty.js file onload to loop through, find the span.timestamp and operate on innerHTML based on the overloaded attribute...
Credits to Ajaxian for finally posting something useful
. . .
And today's quote of the day (paraphrased from an interview):
Interviewee: I'm not sure what Web 2.0 is...
Interviewer: Me neither.
Hooray for buzzwords!
Comment with Facebook
Want to comment with Tabulas?. Please login.
jinshil
yuhoo7
linders1025