Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Timestamp is easy to compare?

Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
03-12-2007 11:47
I am attempting to check in a script whether or not a particular time has passed. It seemed from the wiki that llGetTimestamp() is supposed to be easy to compare two times. I do not need to know the difference between them, only if one is "greater" than another. How is this easy? Is there a way beyond converting each one to hours and minutes (all the accuracy I need) and then comparing?

Also, it does not specifically say on the wiki (that I could find), but is the return of llGetTimestamp() based on GMT?

Thanks,
Baron Hauptmann
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
03-12-2007 12:00
llGetUnixTime might be more suited to your purposes if you're looking to compare hours and minutes. Using that, you can get a difference as the number of seconds, and then do a few simple math operations to get hours and minutes.

As the wiki says, llGetTimeStamp "allows exact times and easy sorting, but is not as suited for comparing time as a libc like timestamp." When they say "easy sorting", they mean easy string sorting, that is, if you sort things of the format YYYY-MM-DDThh:mm:ss.ff..fZ, it will be chronological.

Comparing timestamps is rather difficult-- but the wiki does have a code example of how to do it.

Perhaps LibraryTimeElapsed may be what you're looking for.
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
03-12-2007 12:57
Okay. And as far as I know, the only way of "sorting" two items would be to put them in a list and then sort. I was just wondering if there were a way of "alphabetizing" two strings, ie, see which one *would* come first if put into a list.

So, the solution seems to me to either: convert hh:mm to seconds past midnight and compare to llGetWallclock *OR* put both items in a list, sort them, and compare one of them with the first element to see if it is indeed first. Any idea which one is less resource-intensive?

Baron
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
03-12-2007 13:04
Sorting would be faster, but I wouldn't recommend using llGetTimeStamp if all you care about is time difference.
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
03-12-2007 13:16
Actually, I don't care about the time difference. I just want to know if a time has been passed. Basically, I want to read a time from a notecard such as 14:45 and see if SL time is later than that. I thought that if I could compare text strings using the appropriate part of llGetTimestamp, that would be the easiest. Am I better off converting 14:45 to seconds past midnight and seeing if that is larger than llGetWallclock, then?

Sorry if I'm being thick-headed,
Baron