Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

PDT timestamp?

Vanessa Niven
Registered User
Join date: 28 Dec 2006
Posts: 24
08-16-2007 07:52
Hi, I am needing a timestamp in PDT (SL time).
The llGetTimestamp presents the date and time in UTC timezone, but I would rather not spend 25% of my script's capacity on a timezone conversion function from UTC to PST8PDT. Any suggestions for an efficient way to do this (without contacting the web/http)

Edit: I'v also looked at llGetWallClock which is in the right timezone but it doesn't include the date.
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
08-16-2007 13:36
Take a look at the last example script entry on this page...

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetTimestamp

Just adjust the output of tha function and you will be done :)

/esc
_____________________
http://slurl.com/secondlife/Together
Vanessa Niven
Registered User
Join date: 28 Dec 2006
Posts: 24
08-16-2007 23:38
Thanks, I did read the wiki on that one, but that code takes up about 20% of the script's capacity, for something that should be a function in LSL to begin with. Any other way?

edit: I put this in and ran a memcheck, the convert routine ends up taking around 12% of the total 16k available for the script. (I was getting the 20% before from the comments included doing a measure on disk)
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
08-17-2007 12:32
You can also strip out a lot of the code if you don't need dayofweek stuff. It's the best I could come up with that would be 100% reliable.

Regs
/esc
_____________________
http://slurl.com/secondlife/Together
Bones Outlander
Registered User
Join date: 16 Jan 2008
Posts: 30
02-10-2008 23:23
I just tried using the code referenced above but it's not returning the correct date.

llGetTimestamp returns " 2008-02-11T06:33:02.798491Z"

The function is returning "Sun 14/10/2007 10:33 pm"

The Day and Time are correct, but the date is way out.

Any ides?

Thanks.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-10-2008 23:49
There must be a web service out there that can return a PDT time/date via HTTP. Since minutes and seconds aren't affected by timezone (at least between PDT/PST and GMT/UTC), you can extract that portion from the LSL timestamp for accuracy.
Bones Outlander
Registered User
Join date: 16 Jan 2008
Posts: 30
02-11-2008 05:46
I've found the problem, the month/year manipulation to determine the weekday was changing the month/year when the date string was build.

So I changed this section to build the date string with the correct month/year before doing the manipulation.

CODE

// Determine the day of the week
// This highly non-intuitive code is based on an algorithm
// from http://mathforum.org/library/drmath/view/55837.html
string date = " " + (string)month + "/" + (string)day + "/" + (string)year;
if (month < 3) {
month += 12;
--year;
}

integer weekday_number = (day + 2 * month + (3 * (month + 1)) / 5
+ year + year / 4 - year / 100 + year / 400 + 2) % 7;

// Build the PST date string (fixed format)
date = llGetSubString(llList2String(weekday_names, weekday_number), 0, 2) + date;

// Convert the hour to am/pm