One of the things I've always wanted to reproduce in Notes is Ruby's time_ago_in_words function. You've probably seen it in use, even if you didn't realise. Ever seen a website where the creation date of entries on it are shown not as a date but as a description of how long ago it was in words. Example include:
- This was posted less than a minute ago.
- This entry was created about 2 hours ago.
There are more examples if you follow the link I posted above. You get the idea though, right?
What I love about it is the way (as a user) you get an instant idea of when it happened. It seems a much better way for the human mind to get an idea of the timescales involved. While displaying a normal date works it just isn't as easy for the user to digest.
You can see an example of the principle in use on Digg.com. See this search for page. Notice each result has the time is was "made popular" next to it in (red) human-readable text.
Not wanting to procrastinate any longer I finally got round to porting the code to LotusScript. You can see the original Ruby code/logic in the link above if you click "show source".
Here's the LotusScript class I created. To use in LotusScript, you just do this:
Dim d As New DateHelper Print DEXT.Document.Since(0) + " is " + d.TimeSince(DEXT.Document.Since(0), True)
In this case the code is from a WQS agent of a Form which has a DateTime field on it called "Since". You can see an example of it in use here.
Do us a favour and test the logic out would you?
I know it doesn't handle future dates yet but how well do you think it handles past dates?
Putting It To Use
How useful is this function to us Notes developers? We're used to using Views to show documents. This method can't be used in Views though as they wouldn't be able to index. It's only really useful if you're using a WQO Agent to display a set of documents.
As an example, take the calendar view in the DEXT demo. This whole "view" is generated on the fly by a LotusScript WQO agent. Notice now that the time the entry was added is show below the title in "words".
So, what do you think?