This can be done by dllcalling function or two from msvcrt.dll. Limitation of that way is that it cannot proceed negative EPOCH times and is limited to maximum year of 2038 (3000). Probably there is some other function inside some other dll since Javascript has this as built-in function and for example VBS can deal with "negative" times. Anyway, this is done without DllCall(). It is completley based on Date.au3 and functions inside it. - Why did I extract this out of Date.au3? Because this way these two functions are about 6-7 times faster than using Date.au3. - Speed compared to some other methods? Incredible! Impressive! omg! - Why? Date.au3 is very resourceful script. When I look at functions inside of it I'm starting to wonder if people who wrote them are humans at all? I have serious suspicions about Jos van der Zande. I think that he (it!) is some sort of artificial intelligence. I think that that entity has no form but exists in form that is far beyond our... something. I'm serious. Functions with small example:
ConsoleWrite("EPOCH time 1234567890 is " & _Epoch_decrypt(1234567890) & @CRLF)
ConsoleWrite("Date 4712/12/31 23:59:59 is EPOCH " & _Epoch_encrypt("4712/12/31 23:59:59") & @CRLF)
Func _EPOCH_decrypt($iEpochTime)
Local $iDayToAdd = Int($iEpochTime / 86400)
Local $iTimeVal = Mod($iEpochTime, 86400)
If $iTimeVal < 0 Then
$iDayToAdd -= 1
$iTimeVal += 86400
EndIf
Local $i_wFactor = Int((573371.75 + $iDayToAdd) / 36524.25)
Local $i_xFactor = Int($i_wFactor / 4)
Local $i_bFactor = 2442113 + $iDayToAdd + $i_wFactor - $i_xFactor
Local $i_cFactor = Int(($i_bFactor - 122.1) / 365.25)
Local $i_dFactor = Int(365.25 * $i_cFactor)
Local $i_eFactor = Int(($i_bFactor - $i_dFactor) / 30.6001)
Local $aDatePart[3]
$aDatePart[2] = $i_bFactor - $i_dFactor - Int(30.6001 * $i_eFactor)
$aDatePart[1] = $i_eFactor - 1 - 12 * ($i_eFactor - 2 > 11)
$aDatePart[0] = $i_cFactor - 4716 + ($aDatePart[1] < 3)
Local $aTimePart[3]
$aTimePart[0] = Int($iTimeVal / 3600)
$iTimeVal = Mod($iTimeVal, 3600)
$aTimePart[1] = Int($iTimeVal / 60)
$aTimePart[2] = Mod($iTimeVal, 60)
Return StringFormat("%.2d/%.2d/%.2d %.2d:%.2d:%.2d", $aDatePart[0], $aDatePart[1], $aDatePart[2], $aTimePart[0], $aTimePart[1], $aTimePart[2])
EndFunc
Func _Epoch_encrypt($date)
Local $main_split = StringSplit($date, " ")
If $main_split[0] - 2 Then
Return SetError(1, 0, "") ; invalid time format
EndIf
Local $asDatePart = StringSplit($main_split[1], "/")
Local $asTimePart = StringSplit($main_split[2], ":")
If $asDatePart[0] - 3 Or $asTimePart[0] - 3 Then
Return SetError(1, 0, "") ; invalid time format
EndIf
If $asDatePart[2] < 3 Then
$asDatePart[2] += 12
$asDatePart[1] -= 1
EndIf
Local $i_aFactor = Int($asDatePart[1] / 100)
Local $i_bFactor = Int($i_aFactor / 4)
Local $i_cFactor = 2 - $i_aFactor + $i_bFactor
Local $i_eFactor = Int(1461 * ($asDatePart[1] + 4716) / 4)
Local $i_fFactor = Int(153 * ($asDatePart[2] + 1) / 5)
Local $aDaysDiff = $i_cFactor + $asDatePart[3] + $i_eFactor + $i_fFactor - 2442112
Local $iTimeDiff = $asTimePart[1] * 3600 + $asTimePart[2] * 60 + $asTimePart[3]
Return $aDaysDiff * 86400 + $iTimeDiff
EndFuncWhat is really special about this functions is that they cover dates from -4712/12/31 23:59:59 (EPOCH -210831897601) to 2147483647/12/25 20:00:00 (EPOCH 67767976233000000). First date is nothing special but second one is far beyond other converters can convert. Far, far... edit: "comared" is not a word lol