I wrote the CS 462 Office Hours app over the past two days. The most recent iteration tells the user when the next office hour time block will be. Right now, it just formats it as “Thursday (February 3) at 3 PM.” I’d like it to be a little smarter, though, and say something like “this afternoon at 3 PM” or “tomorrow at 10 AM”.
This is similar to Twitter’s relative timestamps on tweets (it says “3 minutes ago” or “23 hours ago;” beyond that it lists the date). In my case, though, it will be the opposite, since we’re dealing with future times.
Basically, it needs to be smart enough to know that an event is today or tomorrow. Beyond that, I just want to display the date and day of the week.
Is there a way to do this with KRL? Do I just need to use logic like this and write a function (or module)?
These are the functions I have:
This should do the trick. Right now I’m testing it with this rule:
However, that doesn’t seem to be working yet. I get this output:
Can anyone see what’s wrong?