Macro Const = Macro
Const cntQuadBaseDate=9.435312e+16
Const cntStrBaseDate ="1899-12-30 00:00:00"
Function DbltoDateTime(ByVal tmpDouble As Double ) As String
Local tmpDateTime As IPowerTime
Local tmpDayValue As Long
Local tmpTimeValue As Double
Local tmpTotalSeconds As Integer
tmpDateTime = Class "PowerTime"
tmpdatetime.filetime=cntquadbasedate
tmpdayvalue=Fix(tmpdouble)
'ztrace Str$(tmpdayvalue)
tmpTimeValue=Frac(tmpDouble)
'ztrace Str$(tmpDouble)
tmpTotalSeconds=Round(tmpTimeValue * 86400,0)
'ztrace Str$(tmpTotalSeconds)
tmpdatetime.adddays(tmpdayvalue)
tmpdatetime.addseconds(tmptotalseconds)
Function = tmpdatetime.datestring & " " & tmpdatetime.TimeString24 & ":" & Format$(tmpdatetime.second,"00")
End Function
'--------------------------------------------------------------------------------
Function PwttoDbl(tmpPwrTime As IPowerTime) As Double
Dim tmpResult As Double
Dim tmpSign As Long
Dim tmpDayValue As Long
Dim tmpTimeValue As Double
Dim tmpBaseDate As IPowerTime
tmpBaseDate = Class "PowerTime"
tmpBaseDate.filetime=cntquadbasedate
tmptimevalue=((tmpPwrTime.Hour *60*60)+(tmpPwrTime.Minute *60)+tmpPwrTime.Second)/86400
tmpBaseDate.timediff(tmppwrtime, tmpsign,tmpDayValue,0,0)
'ztrace Str$(tmpDayValue)
If tmpdayvalue <0 Then
tmpresult= -1
Else
tmpresult= tmpDayValue +tmpTimeValue
End If
'ztrace Str$(tmpresult)
Function = tmpResult
End Function