GridTalk.de
Altenatve zur Unixtimeumberechnung - Druckversion

+- GridTalk.de (https://www.gridtalk.de)
+-- Forum: Werkstatt (https://www.gridtalk.de/forumdisplay.php?fid=4)
+--- Forum: Scripting (https://www.gridtalk.de/forumdisplay.php?fid=23)
+--- Thema: Altenatve zur Unixtimeumberechnung (/showthread.php?tid=3214)



Altenatve zur Unixtimeumberechnung - brenner23 - 28.11.2018

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


RE: Altenatve zur Unixtimeumberechnung - Anachron - 28.11.2018

Warum verwendest du nicht einfach LlGetTimestamp( ); Huh


RE: Altenatve zur Unixtimeumberechnung - brenner23 - 28.11.2018

(28.11.2018, 08:40)Anachron schrieb: Warum verwendest du nicht einfach LlGetTimestamp( ); Huh

weil llGetTimestamp(aktuelle zeit + 3Tage) nicht funktioniert , dieser befehl nur die aktuelle Zeit auswirft und nicht die plus 3 Tage oder so ! Undecided

Das script soll die Aktuelle Zeit nehmen x hinzuaddieren das dann anzeigen wenn ich
bsp ich nehme die werte mit Parse auseinander...
Aktuelle ausfabe 2018-11-28T14:58:24.3156080Z
und addire x tage stunden minuten.... dazu
ergebniss
2018-15-33T35:68:99.3156080Z
Jahr Mon Tag Hour Min Sek Msek

und llGetTimestamp(123456789) wirft ein fehler aus :-)

oder anders gefragt in PHP gibt es

$datum = date("Y m d H i s",$variable) ;
so oder so ähnlich...
sowas bauche ich in LSL

lg


RE: Altenatve zur Unixtimeumberechnung - brenner23 - 29.11.2018

Ich hab das jetzt mit OSSL gelöst 3 zeilen... :-)


RE: Altenatve zur Unixtimeumberechnung - Anachron - 29.11.2018

Wäre schön gewesen, wenn du deine Lösung auch der Allgemeinheit mitgeteilt hättest.Dodgy


RE: Altenatve zur Unixtimeumberechnung - brenner23 - 29.11.2018

(29.11.2018, 16:14)Anachron schrieb: Wäre schön gewesen, wenn du deine Lösung auch der Allgemeinheit mitgeteilt hättest.Dodgy


Code:
string uUnix2StampLst( integer vIntDat ){
//    if (vIntDat / 2145916800){
//        vIntDat = 2145916800 * (1 | vIntDat >> 31);
//    }
//    integer vIntYrs = 1970 + ((((vIntDat %= 126230400) >> 31) + vIntDat / 126230400) << 2);
//    vIntDat -= 126230400 * (vIntDat >> 31);
//    integer vIntDys = vIntDat / 86400;
//    list vLstRtn0 = [vIntDat % 86400 / 3600];
//    list vLstRtn1 = [vIntDat % 3600 / 60];
//    list vLstRtn2 = [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;
// OS Part start    

    string OS_Correctur = (string)osUnixTimeToTimestamp((integer) vIntDat );
    list TimeStamp = llParseString2List(OS_Correctur,["-",":"],["T"]);
    integer vIntYrs = llList2Integer(TimeStamp, 0 );
    vIntDat = llList2Integer(TimeStamp, 1 );
    integer vIntDys = llList2Integer(TimeStamp, 2 );
    list vLstRtn0 = [llList2Integer(TimeStamp, 4 )];
    list vLstRtn1 = [llList2Integer(TimeStamp, 5 )];
    list vLstRtn2 = [llList2Integer(TimeStamp, 6 )];
// OS Part end    
    string out = (string)vIntYrs +"-"+ (string) vIntDat +"-"+ (string) vIntDys +"-"+ (string)vLstRtn0 +"-"+ (string)vLstRtn1 +"-"+ (string)vLstRtn2;
   return (string)out ;
}