Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string GetPSTDate()
- {
- string DateToday = "";
- string DateUTC = llGetDate();
- if (llGetGMTclock() - llGetWallclock() < 0) //if it's negative then 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);
- if (day == 1) // if day is the 1st of a month, fix the date
- {
- if (month == 1) // if it is January
- {
- year = year - 1; // wind back the year
- month = 12; // set the month to December
- day = 31; // set to last day of December
- }
- else
- {
- month = month - 1; // wind back one month
- if(month == 2)
- day = 28 + !(year % 4) - !(year % 100) + !(year % 400);
- else
- day = 31 - (month == 4 || month == 6 || month == 9 || month == 11);
- }
- }
- else
- day = day - 1;
- if(month < 10)
- DateToday = "0";
- DateToday+=(string)month + "-";
- if(day < 10)
- DateToday += "0";
- DateToday+=(string)day;
- return (string)year + "-" + DateToday;
- }
- return DateUTC;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement