Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Date/time arithmetic

MSo Lambert
Registered User
Join date: 16 Aug 2004
Posts: 101
09-23-2004 03:05
I'm sure a lot of functions for those kind of things exist, but I haven't been able to find any, and im really in a hurry :)

I basically need a few functions to deal with various date and time arithmetic, like finding the difference between two dates (in number of days, hours and minutes), adding days, hours or minutes to a date/time, substracting days, hours or minutes from a date/time, etc...

If there are any available functions around, can anyone please point me in the right direction?

If not, I'm willing to pay someone that can provide me some kind of library of date/time functions (just IM me IW so we can work out the details).

Thanks in advance.
_____________________
MSo
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
09-23-2004 06:12
Haha, everyone wants to know the date all of a sudden :)

"I sell some wrist-watches, the source code for which I've tagged GPL. Grab a landmark from my profile picks to find a copy."

I've got stuff in there to convert between UTC date (what llGetDate() returns) and whatever timezone you like.

Which includes some functions to compare if a date is before or after another, or add a day.

I didn't do the difference between two dates, becaues I didn't have a need for it.
_____________________
--
~If you lived here, you would be home by now~
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
09-23-2004 09:11
I have not exhaustively searched for a localtime() type function here. But in terms of a PERL script, what you need to do is convert the text (if not already in numbers) to numbers, and confirm that they are valid numbers IE: a month cannot be larger than 31, hours cannot be larger than 24... that kind of thing.

Then you need to convert the beginning time to seconds, and the ending time to seconds and confirm that the beginning time is NOT after the Ending time... once you have done that, you subtract the beginning from the ending and you'll have a duration which you can then use a reverse of the process you used to get the seconds in the first place, and send that info to your output function.

I have not spent any time with this in LSL, but if you want to look at a PERL script that works in a CGI-BIN environment, THAT I can send. Perhaps that will provide some insight to what is happening with the date/time math. I too want to know more of the functions.
:cool:
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
MSo Lambert
Registered User
Join date: 16 Aug 2004
Posts: 101
09-23-2004 09:47
Thanks Francis, but I need the functions for a closed source project, so I can't use any GPLed code unfortunately. But im sure it will come in handy for other projects/scripts :)

Samhain, I'll go play with some functions, try the approach you mentioned and let you know if I come up with something.
_____________________
MSo
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
09-23-2004 09:57
I'll be IW about 6:00 PM EST send me an IM and if you need that code, I'll send you an URL where you can get it.
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts