• All submissions to this site are governed by Second Life Project Contribution Agreement. By submitting patches and other information using this site, you acknowledge that you have read, understood, and agreed to those terms.
Issue Details (XML | Word | Printable)

Key: SVC-2774
Type: New Feature New Feature
Status: Open Open
Priority: Normal Normal
Assignee: Unassigned
Reporter: Moon Metty
Votes: 2
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
2. Second Life Service - SVC

string llGetPSTDate()

Created: 08/Aug/08 07:57 PM   Updated: 22/Mar/09 05:37 PM
Return to search
Component/s: Scripts
Affects Version/s: None
Fix Version/s: None

Issue Links:
Relates


 Description  « Hide
A function that returns the date in the PST timezone.

=======

Until then we'll have to use something like:

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 day = 31 - (month == 4 || month == 6 || month == 9 || month == 11);
            }
        }
        else day -= 1;
        if (month < 10) DateToday = "0";
        DateToday += (string)month + "-";
        if (day < 10) DateToday += "0";
        return (string)year + "-" + DateToday + (string)day;
    }
    return DateUTC;
}


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
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
Field Original Value New Value
Link This issue Relates to SVC-1385 [ SVC-1385 ]
Moon Metty added a comment - 09/Aug/08 11:39 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
Link This issue is related to by SVC-301 [ SVC-301 ]
Sue Linden made changes - 13/Nov/08 12:06 PM
Workflow jira-2007-12-22a [ 58110 ] jira-2008-11-14 [ 81267 ]
Sue Linden made changes - 13/Nov/08 04:33 PM
Workflow jira-2008-11-14 [ 81267 ] jira-2008-11-14a [ 87908 ]
Sue Linden made changes - 13/Nov/08 04:55 PM
Workflow jira-2008-11-14 [ 87908 ] jira-2008-11-14a [ 95295 ]
Moon Metty made changes - 18/Mar/09 07:25 AM
Link This issue is related to by SVC-3756 [ SVC-3756 ]
Moon Metty made changes - 18/Mar/09 07:26 AM
Description A function that returns the date in the PST timezone.

=======

Until then we'll have to use something like:

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 day = 31 - (month == 4 || month == 6 || month == 9 || month == 11);
            }
        }
        else day -= 1;
        if (month < 10) DateToday = "0";
        DateToday += (string)month + "-";
        if (day < 10) DateToday += "0";
        return (string)year + "-" + DateToday + (string)day;
    }
    return DateUTC;
}
A function that returns the date in the PST timezone.

=======

Until then we'll have to use something like:

{code}
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 day = 31 - (month == 4 || month == 6 || month == 9 || month == 11);
            }
        }
        else day -= 1;
        if (month < 10) DateToday = "0";
        DateToday += (string)month + "-";
        if (day < 10) DateToday += "0";
        return (string)year + "-" + DateToday + (string)day;
    }
    return DateUTC;
}
{code}
Certified Lunasea added a comment - 22/Mar/09 05:37 PM
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 ). You have a vote from me for this one, and those calling for UTC/GMT in SL got my vote as well on their issue ( SVC-1385 ). Hopefully they will eventually fix this problem.

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.