Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Altenatve zur Unixtimeumberechnung
#1
Hallo hier mal was für Spezis.....

Code:
integer gHoursOffset = -7;
integer gFormat = 12;

list uUnix2StampLst( integer vIntDat ){
    if (vIntDat / 2145916800){
        vIntDat = 2145916800 * (1 | vIntDat >> 31);
    }
    integer CalxX = ( ( ( (vIntDat %= 126230400) >> 31)  + vIntDat / 126230400)  << 2    );            
    integer vIntYrs = 1970 + CalxX;
    vIntDat -= 126230400 * (vIntDat >> 31);
    integer vIntDys = vIntDat / 86400;
    list vLstRtn = [vIntDat % 86400 / 3600, vIntDat % 3600 / 60, vIntDat % 60];
    if (789 == vIntDys){
        vIntYrs += 2;
        vIntDat = 2;
        vIntDys = 29;
    }else{
        vIntYrs += (vIntDys -= (vIntDys > 789)) / 365;
        vIntDys %= 365;
        vIntDys += vIntDat = 1;
        integer vIntTmp;
        while (vIntDys > (vIntTmp = (30 | (vIntDat & 1) ^ (vIntDat > 7)) - ((vIntDat == 2) << 1))){
            ++vIntDat;
            vIntDys -= vIntTmp;
        }
    }
    return [vIntYrs, vIntDat, vIntDys] + vLstRtn;
}

default
{
    state_entry()
    {
        llSetTimerEvent(5);
        gHoursOffset *= 3600;
    }

    timer()
    {
        list    datetime = uUnix2StampLst(llGetUnixTime() + gHoursOffset);
        integer hourInt = llList2Integer(datetime, 3);
        string  hourStr = (string)hourInt;

        vector color = <1, 0, 0>;

        if (hourInt >= 12 && hourInt < 13)
            color = <0, 1, 0>;

        if (gFormat == 12)
        {

            if (hourInt > 12)
                hourStr = (string)(hourInt-12) + "PM";

            else if (hourInt == 0)
                hourStr = (string)(hourInt+12) + "AM";

            else if (hourInt == 12)
                hourStr = (string)hourInt + "PM";

            else
                hourStr = (string)hourInt + "AM";
        }

        llSetText(
            llList2String(datetime, 0) + " - " + llList2String(datetime, 1) + " - " +llList2String(datetime, 2) + "\n" +
            hourStr + " : " + llList2String(datetime, 4) + " : " + llList2String(datetime, 5),
            color,
            1
        );
    }
}


Diese LSL script ist eine Uhr die Datum und Jahr anzeigt , die funktion Unixdingens.... ist in viele von meiem Scripten eingebau.... Problem ist ich hab das Jahr 1970 in SL das Aktuelle Jahr !....

Ich bin nicht gerade gu in C## aber es wird wohl irgentwas mit dem %= überlauf und >> << zu tun der in der in der Formel nocht ganz bei OpenSim funtioniert....

Ich berauche eine Funktiopn die mir aus 156039342 den 3.1.2018 um 13.23 macht... z.b.


lg
Zitieren


Nachrichten in diesem Thema
Altenatve zur Unixtimeumberechnung - von brenner23 - 28.11.2018, 00:53

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 2 Gast/Gäste