Yesterday, 06:05 AM
Best of both worlds, UnixTimeStamp with almost the range of a Filetime
(1 Jan 1601 to 31 Dec 30827)
'
(1 Jan 1601 to 31 Dec 30827)

'
Code:
'Unix TimeStamp with one second resolution and almost the range of a filetime (1 Jan 1601 to 31 Dec 30827)
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN () AS LONG
LOCAL lDebug AS LONG: TXT.WINDOW EXE.FULL$, 10,10,45,85 TO lDebug
TXT.PRINT "Now: " & STR$(UnixtimeNowQ())
TXT.PRINT STR$(unixtimeQ(1601,1,1,23,59,59))
TXT.PRINT STR$(unixtimeQ(1970,1,1,0,0,0))
TXT.PRINT STR$(unixtimeQ(30827,12,31,23,59,59))
TXT.COLOR = %RGB_BLUE:TXT.PRINT:TXT.PRINT " ....Press any key to exit": TXT.WAITKEY$: TXT.END
END FUNCTION
FUNCTION UnixTimeNowQ() AS QUAD
LOCAL tmpTime AS IPOWERTIME
tmpTime = CLASS "PowerTime"
tmptime.nowUTC
FUNCTION = tmpTime.filetime/10000000 - 11644473600
END FUNCTION
FUNCTION UnixTimeQ(y AS LONG,m AS LONG,d AS LONG, h AS LONG,mm AS LONG,s AS LONG) AS QUAD
'Input local time, output UTC based on current UTC offset
LOCAL tmpTime AS IPOWERTIME
tmpTime = CLASS "PowerTime"
tmptime.newdate(y,m,d)
tmptime.newtime(h,mm,s)
'debug code - comment out next line for normal function use
TXT.PRINT tmpTime.datestring & " " & tmptime.timestringfull,
tmptime.toUTC
FUNCTION = tmpTime.filetime/10000000 - 11644473600
END FUNCTION
'