' seconds since 01-01-1970. no checks on the argument format ' HT$ is DD-MM-YYYY HH:MM:SS or if opt=1 HT$ is YYYY-MM-DD HH:MM:SS ' Now() returns a suitable string Function UnixTime(HHT$,opt) As integer Local integer n,s,y,m Local String DD$,TT$,HT$ HT$=HHT$ m=Split(HT$," ") If m<>2 then UnixTime=-1:Exit Function DD$=SP$(1):TT$=SP$(2) 'following is error checking, remove if not using IsDate/IsTime due to overhead of regexps '[ If Not IsDate(DD$,opt) Then UnixTime=-1:Exit Function' Not a proper date If Not IsTime(TT$) Then UnixTime=-1:Exit Function' not a proper time '] m=Split(DD$,"-") If m<>3 then UnixTime=-1:Exit Function If opt=0 then y=Val(SP$(3)) else y=Val(SP$(1)) EndIf s=0 For n=1970 To y-1 s=s+365+IsLeapYear(n) Next For n=1 To Val(SP$(2))-1 Select Case n Case 1,3,5,7,8,10 s=s+31 Case 2 s=s+28+IsLeapYear(y) Case 4,6,9,11 s=s+30 End Select Next If opt=0 Then s=86400*(s+Val(SP$(1))-1) Else s=86400*(s+Val(SP$(3))-1) EndIf m=Split(TT$,":") If m<>3 then UnixTime=-1:Exit Function s=s+(3600*Val(SP$(1))) + (60*Val(SP$(2))) + Val(SP$(3)) UnixTime=s End Function