Spotlight on your startscreen: available @OpenNTF

I have embedded the code in AppDev Template project on OpenNTF. This application can be used as the default template for new development projects for the Lotus Notes client.

You can download version 2 of it here.

Notice that dates are displayed in a more human friendly format:

Class DateHelper
Private dt_then As NotesDateTime
Private dt_now As NotesDateTime
Private diff_in_seconds As Long
Private diff_in_minutes As Long

Sub New()
Set dt_now = New NotesDateTime(Now)
End Sub

Function TimeSince(datetime As Variant, includeseconds As Boolean)
Set dt_then = New NotesDateTime(Cstr(datetime))
Dim future As Boolean
Dim since As String
Dim whichway As String

diff_in_seconds = dt_now.TimeDifference(dt_then)

If Sgn(diff_in_seconds) = -1 Then ‘future
future = True
diff_in_seconds = Abs(diff_in_seconds)
whichway = ” away”
Else ‘past
future = False
whichway = ” ago”
End If

diff_in_minutes = Round(diff_in_seconds/60,0)

If diff_in_minutes >= 0 And diff_in_minutes <= 1 Then
If Not includeseconds Then
If diff_in_minutes = 0 Then
since = “less than a minute”
Else
since = “1 minute”
End If
Else
If diff_in_seconds >= 0 And diff_in_seconds <= 4 Then
Since = “less than 5 seconds”
Elseif diff_in_seconds >= 5 And diff_in_seconds <= 9  Then
Since = “less than 10 seconds”
Elseif diff_in_seconds >= 10 And diff_in_seconds <= 19 Then
Since = “less than 20 seconds”
Elseif diff_in_seconds >= 20 And diff_in_seconds <= 39 Then
Since = “half a minute”
Elseif diff_in_seconds >= 40 And diff_in_seconds <= 59 Then
Since = “less than a minute”
Else
Since = “1 minute”
End If
End If
Elseif diff_in_minutes >= 2 And diff_in_minutes <= 44 Then
since =  Cstr(diff_in_minutes) + ” minutes”
Elseif diff_in_minutes >= 45 And diff_in_minutes <= 89 Then
since = “about 1 hour”
Elseif diff_in_minutes >= 90 And diff_in_minutes <= 1439 Then
since = “about ” + Cstr(Round(diff_in_minutes / 60, 0)) + ” hours”
Elseif diff_in_minutes >= 1440 And diff_in_minutes <= 2879 Then
since = “1 day”
Elseif diff_in_minutes >= 2880 And diff_in_minutes <= 43199 Then
since = “about ” + Cstr(Round(diff_in_minutes / 1440, 0)) + ” days”
Elseif diff_in_minutes >= 43200 And diff_in_minutes <= 86399 Then
since = “about 1 month”
Elseif diff_in_minutes >= 86400 And diff_in_minutes <= 525599 Then
Since = Cstr(Round(diff_in_minutes / 43200, 0)) +” months”
Elseif diff_in_minutes >= 525600 And diff_in_minutes <= 1051199 Then
Since = “about 1 year”
Else
since = “over ” + Cstr(Round(diff_in_minutes / 525600, 0)) + ” years”
End If

TimeSince = since + whichway
End Function
End Class

Let’s try to set a new download record in 2011 =)

Advertisements

12 thoughts on “Spotlight on your startscreen: available @OpenNTF

  1. Lars Berntrop-Bos 2011-January-13 / 1:50 pm

    How about using Julian’s LotusScript formatter , I believe that’s in OpenNTF too 😉

    • Patrick Kwinten 2011-January-13 / 3:35 pm

      I never used it but maybe it’s time I should. I will take a look at it, thank you for the tip!

    • D. Geelong 2011-January-13 / 10:25 pm

      test:

      .lotusscript { font-family: sans-serif; font-size: 9pt; color: black; }
      .ls-comment { color: green; }
      .ls-quote { color: black; }
      .ls-datatype { color: black; }
      .ls-operator { color: blue; }
      .ls-keyword { color: blue; }
      .ls-statement { color: blue; }
      .ls-function { color: blue; }
      .ls-class { color: black; }
      .ls-constant { color: purple; }

      Class DateHelper
      Private dt_then As NotesDateTime
      Private dt_now As NotesDateTime
      Private diff_in_seconds As Long
      Private diff_in_minutes As Long
      
      Sub New()
      Set dt_now = New NotesDateTime(Now)
      End Sub
      
      Function TimeSince(datetime As Variant, includeseconds As Boolean)
      Set dt_then = New NotesDateTime(Cstr(datetime))
      Dim future As Boolean
      Dim since As String
      Dim whichway As String
      
      diff_in_seconds = dt_now.TimeDifference(dt_then)
      
      If Sgn(diff_in_seconds) = -1 Then ‘future
      future = True
      diff_in_seconds = Abs(diff_in_seconds)
      whichway = ” away”
      Else ‘past
      future = False
      whichway = ” ago”
      End If
      
      diff_in_minutes = Round(diff_in_seconds/60,0)
      
      If diff_in_minutes >= 0 And diff_in_minutes <= 1 Then
      If Not includeseconds Then
      If diff_in_minutes = 0 Then
      since = “less than a minute”
      Else
      since = “1 minute”
      End If
      Else
      If diff_in_seconds >= 0 And diff_in_seconds <= 4 Then
      Since = “less than 5 seconds”
      Elseif diff_in_seconds >= 5 And diff_in_seconds <= 9  Then
      Since = “less than 10 seconds”
      Elseif diff_in_seconds >= 10 And diff_in_seconds <= 19 Then
      Since = “less than 20 seconds”
      Elseif diff_in_seconds >= 20 And diff_in_seconds <= 39 Then
      Since = “half a minute”
      Elseif diff_in_seconds >= 40 And diff_in_seconds <= 59 Then
      Since = “less than a minute”
      Else
      Since = “1 minute”
      End If
      End If
      Elseif diff_in_minutes >= 2 And diff_in_minutes <= 44 Then
      since =  Cstr(diff_in_minutes) + ” minutes”
      Elseif diff_in_minutes >= 45 And diff_in_minutes <= 89 Then
      since = “about 1 hour”
      Elseif diff_in_minutes >= 90 And diff_in_minutes <= 1439 Then
      since = “about ” + Cstr(Round(diff_in_minutes / 60, 0)) + ” hours”
      Elseif diff_in_minutes >= 1440 And diff_in_minutes <= 2879 Then
      since = “1 day”
      Elseif diff_in_minutes >= 2880 And diff_in_minutes <= 43199 Then
      since = “about ” + Cstr(Round(diff_in_minutes / 1440, 0)) + ” days”
      Elseif diff_in_minutes >= 43200 And diff_in_minutes <= 86399 Then
      since = “about 1 month”
      Elseif diff_in_minutes >= 86400 And diff_in_minutes <= 525599 Then
      Since = Cstr(Round(diff_in_minutes / 43200, 0)) +” months”
      Elseif diff_in_minutes >= 525600 And diff_in_minutes <= 1051199 Then
      Since = “about 1 year”
      Else
      since = “over ” + Cstr(Round(diff_in_minutes / 525600, 0)) + ” years”
      End If
      
      TimeSince = since + whichway
      End Function
      End Class
      

      This LotusScript was converted to HTML using the ls2html routine,provided by Julian Robichaux at nsftools.com.

      • Patrick Kwinten 2011-January-14 / 8:27 am

        thanks but no thanks i guess =)

  2. Declan Lynch 2011-January-13 / 4:08 pm

    It would be really nice if you credited the original authors of this code and made sure your licenses were in order for using the code and putting it into OpenNTF projects.

    This code originates on CodeStore ( http://www.codestore.net/store.nsf/unid/BLOG-20080909?OpenDocument ). if you download the lss file you’ll see that it is line-by-line exactly the same.

    With no explicit license given on his website the implied license is that it is copyright Rockall Design as stated at the bottom of every screen on his website and thus can’t be used in any OpenSource project.

    • Mark Hughes 2011-January-13 / 5:15 pm

      Will that get you baned from OpenNTF?

      • Declan Lynch 2011-January-13 / 5:38 pm

        It means the project can’t be cleared by the IP Manager.

        The IP Manager will then work with you to tell you what code is not licensed correctly and assist, where possible, to make sure you have the correct licenses or remove/rewrite the code somehow.

        If somebody were to ignore the IP Manager and refuse to get the licensing corrected then the project could be in danger of been removed from OpenNTF but I’m guessing that OpenNTF would rather help resolve the licensing issues then be put into position to have to close a project.

        Also, if there is a project on OpenNTF that contains some of your code then you need to let the IP Manager know, that way they can contact the project owner and let them know. There have been cases where the author got the code from some other site that had ripped it from the originator without credit so the project owner didn’t know it was incorrectly licensed.

      • Peter Tanner 2011-January-17 / 9:48 pm

        Currently we (OpenNTF) haven’t been scanning the code unless the project owners would like us to place it into the Catalog. So, non-Catalog code on OpenNTF has no process that prevents the posting of code that contains IP issues. So, for any posting, it is always best to check if the project is also in the Catalog.

        With the new IP Policy, things are going to get somewhat more strict. All submitters will have to be covered by an ICLA or CCLA.

        But Declan is right. The OpenNTF IP Manager (that’s me) is happy to work with anyone to help them remove potential IP issues from their OpenNTF postings.

    • Patrick Kwinten 2011-January-13 / 8:51 pm

      I was not aware it came from that site. I guess best thing would be to remove it.

      • Declan Lynch 2011-January-13 / 10:41 pm

        Where did you get it from? If it’s on a site somewhere then that site has ripped it off without crediting the original author. Of course, if you had credited the site you got it from then this discussion would be happening at that site, not yours.

        Nobody is saying that you should remove it, just get it licensed correctly. That may involve just sending jake an email and asking for permission to use the code in an Apache licensed product.

      • Patrick Kwinten 2011-January-14 / 8:26 am

        Yes it came from one of our developers. I have sent an email to Jake for permission. We’ll see what he will answer. At least I found now via this post an alternative for it in SSJS.

  3. D. Geelong 2011-January-13 / 10:24 pm

    what is it with copyrights? its seems like flashing your johnson in public and claiming that nobody may take pictures of it. i wonder how legitimate placing a copyright text actually is?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s