English
Source / code snippets

date Timestamp Unix Utc Time

 

Christian
Schneider
GetUnixtime() prepares from the actually System-Time a Unix-Timestamp [...]  (sec since 01.01.1970 0:00 watch)
->Rückgabewert: Int

UnixToUTC() GetControlParas (B a Timestamp in UTC-Time [...] 
-> Parameter: Timestamp (Int)
-> Return Value: String (stature: TTMMJJSSmmss)

UnixToLocal() GetControlParas (B a Timestamp in local System-Time
-> Parameter: Timestamp (Int)
-> Return Value: String (stature: TTMMJJSSmmss)
CompileMarkSeparation
Definitionen
Def GetSystemTime(1) !"Kernel32.dll","GetSystemTime"
Def SystemTimeToTzSpecificLocalTime(3) !"Kernel32.dll","SystemTimeToTzSpecificLocalTime"
Programm start
CLS
var timestamp% = GetUnixtime()
Print "Timestamp: "+str$(timestamp%)
var time_utc$ = UnixToUTC(timestamp%)
Print "UTC-Zeit: "+left$(time_utc$,2)+"."+mid$(time_utc$,3,2)+"."+mid$(time_utc$,5,4)+" - "+mid$(time_utc$,9,2)+":"+mid$(time_utc$,11,2)+":"+mid$(time_utc$,13,2)
var time_lokal$ = UnixToLocal(timestamp%)
Print "Lokalzeit: "+left$(time_lokal$,2)+"."+mid$(time_lokal$,3,2)+"."+mid$(time_lokal$,5,4)+" - "+mid$(time_lokal$,9,2)+":"+mid$(time_lokal$,11,2)+":"+mid$(time_lokal$,13,2)
Waitkey
Programm ende

Proc GetUnixtime

    Declare SYSTEMTIME#
    Dim SYSTEMTIME#,16
    Declare ut_Jahr%,ut_Monat%,ut_Tag%,ut_Stunde%,ut_Minute%,ut_Sekunde%
    var ut_schalttag%=0
    Declare tage_bis_monatsanfang%[12]
    tage_bis_monatsanfang%[0]=0
    tage_bis_monatsanfang%[1]=0
    tage_bis_monatsanfang%[2]=31
    tage_bis_monatsanfang%[3]=59
    tage_bis_monatsanfang%[4]=90
    tage_bis_monatsanfang%[5]=120
    tage_bis_monatsanfang%[6]=151
    tage_bis_monatsanfang%[7]=181
    tage_bis_monatsanfang%[8]=212
    tage_bis_monatsanfang%[9]=243
    tage_bis_monatsanfang%[10]=273
    tage_bis_monatsanfang%[11]=304
    tage_bis_monatsanfang%[12]=334
    GetSystemTime(SYSTEMTIME#)
    ut_Jahr%=@Word(SYSTEMTIME#,0)
    ut_Monat%=@Word(SYSTEMTIME#,2)
    ut_Tag%=@Word(SYSTEMTIME#,6)
    ut_Stunde%=@Word(SYSTEMTIME#,8)
    ut_Minute%=@Word(SYSTEMTIME#,10)
    ut_Sekunde%=@Word(SYSTEMTIME#,12)

    if (ut_monat%>2) & (ut_jahr% MOD 4 =0) & (ut_jahr% MOD 100 <> 0)

        ut_schalttag%=1

    elseif (ut_monat%>2) & (ut_jahr% MOD 400 = 0)

        ut_schalttag%=1

    endif

    DISPOSE SYSTEMTIME#
    Return ((tage_bis_monatsanfang%[ut_Monat%]*24*60*60) + (ut_Tag%-1)*24*60*60)+ (ut_Sekunde% + ut_Minute%*60 + ut_Stunde%*60*60) + ((ut_Jahr%-1970) * 365 * 24*60*60 + ((((ut_Jahr%-1)-1968)4 - ((ut_Jahr%-1)-1900)100 + ((ut_Jahr%-1)-1600)400)*24*60*60))+(ut_schalttag%*24*60*60)

Endproc

Proc UnixToUTC

    Parameters ut_timestamp%,ut_mode%
    Declare ut_schaltjahr%,ut_schalttage%,ut_wochentag%
    Declare ut_jahr%,ut_monat%,ut_tag%,ut_stunde%,ut_minute%,ut_sekunde%

    if ut_mode%=1

        select ((ut_timestamp%  86400) mod 7)

            caseof 1 Freitag

            ut_wochentag%=5

            caseof 2 Samstag

            ut_wochentag%=6

            caseof 3 Sonntag

            ut_wochentag%=0

            caseof 4 Montag

            ut_wochentag%=1

            caseof 5 Dienstag

            ut_wochentag%=2

            caseof 6 Mittwoch

            ut_wochentag%=3

            caseof 7 Donnerstag

            ut_wochentag%=4

        endselect

    endif

    ut_jahr%=ut_timestamp%  (365*24*60*60) + 1970
    ut_schalttage%=(((ut_Jahr%-1)-1968)4 - ((ut_Jahr%-1)-1900)100 + ((ut_Jahr%-1)-1600)400)

    while (ut_timestamp%-(((ut_jahr%-1970)*365+ut_schalttage%)*24*60*60)+3600) < 0

        case (ut_timestamp%-(((ut_jahr%-1970)*365+ut_schalttage%)*24*60*60)+3600) < 0:ut_jahr%=ut_jahr%-1

    endwhile

    if (ut_jahr% MOD 4 =0) & (ut_jahr% MOD 100 <> 0)

        ut_schaltjahr%=1

    elseif (ut_jahr% MOD 400 = 0)

        ut_schaltjahr%=1

    endif

    ut_timestamp%=(ut_timestamp%-(((ut_jahr%-1970)*365+ut_schalttage%)*24*60*60))

    Select (ut_timestamp%  (24*60*60) + 1)

        CaseOF > 334+ut_schaltjahr%

        ut_monat%=12
        ut_timestamp%=ut_timestamp%-((334+ut_schaltjahr%)*24*60*60)

        CaseOF > 304+ut_schaltjahr%

        ut_monat%=11
        ut_timestamp%=ut_timestamp%-((304+ut_schaltjahr%)*24*60*60)

        CaseOF > 273+ut_schaltjahr%

        ut_monat%=10
        ut_timestamp%=ut_timestamp%-((273+ut_schaltjahr%)*24*60*60)

        CaseOF > 243+ut_schaltjahr%

        ut_monat%=9
        ut_timestamp%=ut_timestamp%-((243+ut_schaltjahr%)*24*60*60)

        CaseOF > 212+ut_schaltjahr%

        ut_monat%=8
        ut_timestamp%=ut_timestamp%-((212+ut_schaltjahr%)*24*60*60)

        CaseOF > 181+ut_schaltjahr%

        ut_monat%=7
        ut_timestamp%=ut_timestamp%-((181+ut_schaltjahr%)*24*60*60)

        CaseOF > 151+ut_schaltjahr%

        ut_monat%=6
        ut_timestamp%=ut_timestamp%-((151+ut_schaltjahr%)*24*60*60)

        CaseOF > 120+ut_schaltjahr%

        ut_monat%=5
        ut_timestamp%=ut_timestamp%-((120+ut_schaltjahr%)*24*60*60)

        CaseOF > 90+ut_schaltjahr%

        ut_monat%=4
        ut_timestamp%=ut_timestamp%-((90+ut_schaltjahr%)*24*60*60)

        CaseOF > 59+ut_schaltjahr%

        ut_monat%=3
        ut_timestamp%=ut_timestamp%-((59+ut_schaltjahr%)*24*60*60)

        CaseOF > 31

        ut_monat%=2
        ut_timestamp%=ut_timestamp%-(31*24*60*60)
        Otherwise
        ut_monat%=1

    Endselect

    ut_tag% = ut_timestamp%  (24*60*60) + 1
    ut_timestamp% = (ut_timestamp%-((ut_tag%-1) * 24*60*60))
    ut_stunde% = ut_timestamp%  (60*60)
    ut_timestamp% = (ut_timestamp%-((ut_stunde%)*60*60))
    ut_minute% = ut_timestamp%  60
    ut_timestamp% = (ut_timestamp%-((ut_minute%)*60))
    ut_sekunde% = ut_timestamp%

    ifnot ut_mode%=1

        Return @If(ut_tag%<10,"0","")+str$(ut_tag%)+@If(ut_monat%<10,"0","")+str$(ut_monat%)+str$(ut_jahr%)+@If(ut_stunde%<10,"0","")+ str$(ut_stunde%)+@If(ut_minute%<10,"0","")+str$(ut_minute%)+@If(ut_sekunde%<10,"0","")+str$(ut_sekunde%)

    else

        Return str$(ut_jahr%)+@If(ut_monat%<10,"0","")+str$(ut_monat%)+str$(ut_wochentag%)+@If(ut_tag%<10,"0","")+str$(ut_tag%)+@If(ut_stunde%<10,"0","")+str$(ut_stunde%)+@If(ut_minute%<10,"0","")+str$(ut_minute%)+@If(ut_sekunde%<10,"0","")+str$(ut_sekunde%)

    EndIF

Endproc

Proc UnixToLocal

    Parameters u2l%
    Declare SYSTEMTIME#,SYSTEMTIME2#,u2l_return$
    Dim SYSTEMTIME#,16
    Dim SYSTEMTIME2#,16
    Declare ut_rückg$
    ut_rückg$ = UnixToUTC(u2l%,1)
    Word SYSTEMTIME#,0=val(left$(ut_rückg$,4))
    Word SYSTEMTIME#,2=val(mid$(ut_rückg$,5,2))
    Word SYSTEMTIME#,4=val(mid$(ut_rückg$,7,1))
    Word SYSTEMTIME#,6=val(mid$(ut_rückg$,8,2))
    Word SYSTEMTIME#,8=val(mid$(ut_rückg$,10,2))
    Word SYSTEMTIME#,10=val(mid$(ut_rückg$,12,2))
    Word SYSTEMTIME#,12=val(mid$(ut_rückg$,14,2))
    Word SYSTEMTIME#,14=1
    SystemTimeToTzSpecificLocalTime(0,SYSTEMTIME#,SYSTEMTIME2#)
    u2l_return$ = @IF(@Word(SYSTEMTIME2#,6)<10,"0","")+str$(@Word(SYSTEMTIME2#,6))+@IF(@Word(SYSTEMTIME2#,2)<10,"0","")+str$(@Word(SYSTEMTIME2#,2))+str$(@Word(SYSTEMTIME2#,0))+@IF(@Word(SYSTEMTIME2#,8)<10,"0","")+str$(@Word(SYSTEMTIME2#,8))+@IF(@Word(SYSTEMTIME2#,10)<10,"0","")+str$(@Word(SYSTEMTIME2#,10))+@IF(@Word(SYSTEMTIME2#,12)<10,"0","")+str$(@Word(SYSTEMTIME2#,12))
    Dispose SYSTEMTIME#,SYSTEMTIME2#
    Return u2l_return$

Endproc

 
XProfan 11| Vista(64) SP2
05/24/10  
 




Christian
Schneider
Errors in the Schaltjahren fixed
 
XProfan 11| Vista(64) SP2
05/24/10  
 




Christian
Schneider
now too andersrum possible (Timestamp -> Realzeit)
Umrechnung in Lokalzeit follows
 
XProfan 11| Vista(64) SP2
05/24/10  
 




Dieter
Zornow
mmh, by me comes the 44.01.2009 out, bisschen plenty days.
 
Er ist ein Mann wie ein Baum. Sie nennen ihn Bonsai., Win 7 32 bit und Win 7 64 bit, mit XProfan X2
05/24/10  
 




Christian
Schneider
your response has unfortunately with my last Update überschnitten. can you whom actually code please again testing?
 
XProfan 11| Vista(64) SP2
05/24/10  
 



@Christian: Related UnixTime [...]  as native function to Presentation of WOD - vlt. to that comparison. One nativer Rückweg alà MKTime missing me in xpse yet.
 
05/24/10  
 




Christian
Schneider
The "Rückweg" lying with. See UnixToUTC()

though as Mustercode well sooner unfit. stick still of a or others Workaround with drin. me I ment mainly around the Timestamp, The Rest is sooner one by-product from Basteltrieb

where the actually code with my Tests brauchbare Results abliefert

Michaels code have I zwischenzeitlich too discover, though has me the Assemblerteil successful into getaway beaten ;)
 
XProfan 11| Vista(64) SP2
05/24/10  
 




Dieter
Zornow
goes unfortunately still not, see Image

29 kB
Hochgeladen:05/25/10
Downloadcounter233
Download
 
Er ist ein Mann wie ein Baum. Sie nennen ihn Bonsai., Win 7 32 bit und Win 7 64 bit, mit XProfan X2
05/25/10  
 



Christian tailor, Beitrag=57201, Zeitpunkt=24.05.2010
Michaels code have I zwischenzeitlich too discover, though has me the Assemblerteil successful into getaway beaten ;)


hey, You need still only Print UnixTime() write. ^^

If your UnixToUTC correctly functions, then would I from it later too gladly one native MKTime make and it in XPSE as real function to assimilate.
 
05/25/10  
 




Christian
Schneider
Dieter Zornow, Beitrag=57203, Zeitpunkt=25.05.2010
goes unfortunately still not, see Image


I have it by me again under GMT+7 tested, too there funktionierts. ought to means Schonmal not on the Zeitzone lying.
I could me theoretical yet present the The Beta possible athwart schießt. Have unfortunately this time The Subscription bleary and can think I first in the running the week so testing. have you time a with 11.2 create exe appended.

Edit: my naturally 11.2

1.037 kB
Hochgeladen:05/25/10
Downloadcounter141
Download
31 kB
Hochgeladen:05/25/10
Downloadcounter227
Download
 
XProfan 11| Vista(64) SP2
05/25/10  
 



You mind already at calculate, that 32-bit for a TimeStamp not always wealthy must !? (überschaue I now not)

last attachment functions by me here on one 32-bit-XP-Home correctly.
 
05/25/10  
 




Christian
Schneider
iF, Beitrag=57204, Zeitpunkt=25.05.2010
hey, You need still only Print UnixTime() write. ^^


the likes his, but I try shred To avoid, The I not even in the Ansatz understand (Assembler..).

iF, Beitrag=57204, Zeitpunkt=25.05.2010
If your UnixToUTC correctly functions, then would I from it later too gladly one native MKTime make and it in XPSE as real function to assimilate.


will be you there not detain ^^

To to that 19. january 2038 ought to it with 32bit no Problems give.
 
XProfan 11| Vista(64) SP2
05/25/10  
 




Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

20.835 Views

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie