|
|
|
[
Permlink
| « Hide
]
Coyote Pace added a comment - 09/Aug/08 10:26 AM
Another way to resolve this problem is to simply redefine SL time as UTC.
Coyote Pace made changes - 09/Aug/08 10:26 AM
Coyote, I agree it would have been better if we all used UTC/GMT in secondlife. After all, it's the standard of the world.
Unfortunately, it would take a papal decree to change the SL-time, effectively saying: "Sorry, your existing content is now obsolete." A very tough decision to make, it will probably never happen.
McCabe Maxsted made changes - 10/Aug/08 02:22 PM
Sue Linden made changes - 13/Nov/08 12:06 PM
Sue Linden made changes - 13/Nov/08 04:33 PM
Sue Linden made changes - 13/Nov/08 04:55 PM
Moon Metty made changes - 18/Mar/09 07:25 AM
Moon Metty made changes - 18/Mar/09 07:26 AM
I am in favor of adding a function to LSL to get a relevant date to the time served up to the viewer, however I would also be in favor of using UTC/GMT as the official in-world time as well. I found this issue with thanks to Harleen in a post to a related issue ( SVC-3756
In the mean time, I have posted what I hope to be an accurate re-write of the above mentioned code aimed at novice LSL scripters to help them get a relevant date and will re-post it here to hopefully gain more attention to it so those new to the language can understand what you have done in the above code. If you could suggest any improvements for the sake of understanding please let me know. GetPSTDate.LSL string GetPSTDate()
{
string DateUTC = llGetDate();
if (llGetGMTclock() < llGetWallclock())
{ // the date has changed.
integer year = (integer)llGetSubString(DateUTC, 0, 3);
integer month = (integer)llGetSubString(DateUTC, 5, 6);
integer day = (integer)llGetSubString(DateUTC, 8, 9);
string DateToday;
if (day == 1)
{ // if day is the 1st of a month, fix the date
if (month == 1)
{ // if it is January
year -= 1;
month = 12;
day = 31;
}
else
{
month -= 1;
if(month == 2)
{
day = 28 + !(year % 4) - !(year % 100) + !(year % 400);
}
else if(month == 4 || month == 6 || month == 9 || month == 11)
{
day = 30;
}
else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
{
day=31;
}
}
}
else
{
day -= 1;
if (month < 10)
{
DateToday = "0";
DateToday += (string)month + "-";
}
if (day < 10)
{
DateToday += "0";
}
}
return (string)year + "-" + DateToday + (string)day;
}
return DateUTC;
}
I hope this helps someone out there. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||