Advertisement
Dorex

Untitled

Nov 20th, 2023
2,457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string GetPSTDate()
  2. {
  3.     string DateToday = "";
  4.     string DateUTC = llGetDate();
  5.     if (llGetGMTclock() -  llGetWallclock() < 0) //if it's negative then the date has changed.
  6.     {
  7.         integer year = (integer)llGetSubString(DateUTC, 0, 3);
  8.         integer month = (integer)llGetSubString(DateUTC, 5, 6);
  9.         integer day = (integer)llGetSubString(DateUTC, 8, 9);
  10.        
  11.         if (day == 1) // if day is the 1st of a month, fix the date
  12.         {
  13.             if (month == 1) // if it is January
  14.             {
  15.                 year = year - 1; // wind back the year
  16.                 month = 12; // set the month to December
  17.                 day = 31; // set to last day of December
  18.             }
  19.             else
  20.             {
  21.                 month = month - 1; // wind back one month
  22.                 if(month == 2)
  23.                     day = 28 + !(year % 4) - !(year % 100) + !(year % 400);
  24.                 else
  25.                     day = 31 - (month == 4 || month == 6 || month == 9 || month == 11);
  26.             }
  27.         }
  28.         else
  29.             day = day - 1;
  30.         if(month < 10)
  31.             DateToday = "0";
  32.         DateToday+=(string)month + "-";
  33.         if(day < 10)
  34.             DateToday += "0";
  35.         DateToday+=(string)day;
  36.         return (string)year + "-" + DateToday;
  37.     }
  38.     return DateUTC;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement