Maybe someone can help on this attempt to follow a recommendation
in the msdn Knowledge Base on how to best do datetime arithmatic.
My problem is in the conversions to quadword, doing the arithmatic,
and converting back.
#COMPILE EXE
#INCLUDE "Win32API.INC"
'Trying to convert the example from Microsoft recommendations for doing
'simple arithmatic on dates and times
'http://support.microsoft.com/support/kb/articles/Q188/7/68.ASP
FUNCTION TimeStamp() AS STRING
LOCAL tTime AS ASCIIZ * 64
LOCAL st AS systemtime, ft AS FILETIME
LOCAL ONE_SECOND AS QUAD, ONE_MINUTE AS QUAD, _
ONE_HOUR AS QUAD, ONE_DAY AS QUAD, qwResult AS QUAD, _
HiTime???, LoTime???
ONE_SECOND = 10000000 '100 nanosecond intervals
ONE_MINUTE = (60 * ONE_SECOND)
ONE_HOUR = (60 * ONE_MINUTE)
ONE_DAY = (24 * ONE_HOUR)
GetLocalTime st
SystemTimeToFileTime st, ft
'Here I am trying to copy the time into a quadword with c code:-
'(((ULONGULONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime
HiTime??? = (ft.dwHighDateTime)
LoTime??? = (ft.dwLowDateTime)
SHIFT LEFT HiTime???, 32
qwResult = HiTime??? + LoTime???
qwResult = qwResult + 30 * ONE_DAY 'Attempt to add 30 days
'Here I am trying to copy the result back to FILETIME with c code:-
'ft.dwLowDateTime = (DWORD) (qwResult & 0xFFFFFFFF);
'ft.dwHighDateTime = (DWORD) (qwResult >> 32);
LoTime = qwResult AND &HFFFFFFFF
SHIFT RIGHT qwResult, 32
HiTime = qwResult
ft.dwLowDateTime = LoTime???
ft.dwHighDateTime = HiTime???
FileTimeToSystemTime ft, st
FUNCTION = TRIM$(STR$(st.wyear)) + _
FORMAT$(st.wMonth,"00") + _
FORMAT$(st.wDay,"00") + _
FORMAT$(st.wHour,"00") + _
FORMAT$(st.wMinute,"00") + _
FORMAT$(st.wSecond,"00") + "." + _
FORMAT$(st.wMilliseconds, "000")
END FUNCTION
FUNCTION PBMAIN
LOCAL TimeString AS STRING
TimeString = TimeStamp
MSGBOX TimeString, 48,"TimeString outside Function TimeStamp"
'I was hoping to display a string showing 30 days later than today
'but I get a date back in 1601 so my attempt to convert the c code
'is not correct.
END FUNCTION
in the msdn Knowledge Base on how to best do datetime arithmatic.
My problem is in the conversions to quadword, doing the arithmatic,
and converting back.
#COMPILE EXE
#INCLUDE "Win32API.INC"
'Trying to convert the example from Microsoft recommendations for doing
'simple arithmatic on dates and times
'http://support.microsoft.com/support/kb/articles/Q188/7/68.ASP
FUNCTION TimeStamp() AS STRING
LOCAL tTime AS ASCIIZ * 64
LOCAL st AS systemtime, ft AS FILETIME
LOCAL ONE_SECOND AS QUAD, ONE_MINUTE AS QUAD, _
ONE_HOUR AS QUAD, ONE_DAY AS QUAD, qwResult AS QUAD, _
HiTime???, LoTime???
ONE_SECOND = 10000000 '100 nanosecond intervals
ONE_MINUTE = (60 * ONE_SECOND)
ONE_HOUR = (60 * ONE_MINUTE)
ONE_DAY = (24 * ONE_HOUR)
GetLocalTime st
SystemTimeToFileTime st, ft
'Here I am trying to copy the time into a quadword with c code:-
'(((ULONGULONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime
HiTime??? = (ft.dwHighDateTime)
LoTime??? = (ft.dwLowDateTime)
SHIFT LEFT HiTime???, 32
qwResult = HiTime??? + LoTime???
qwResult = qwResult + 30 * ONE_DAY 'Attempt to add 30 days
'Here I am trying to copy the result back to FILETIME with c code:-
'ft.dwLowDateTime = (DWORD) (qwResult & 0xFFFFFFFF);
'ft.dwHighDateTime = (DWORD) (qwResult >> 32);
LoTime = qwResult AND &HFFFFFFFF
SHIFT RIGHT qwResult, 32
HiTime = qwResult
ft.dwLowDateTime = LoTime???
ft.dwHighDateTime = HiTime???
FileTimeToSystemTime ft, st
FUNCTION = TRIM$(STR$(st.wyear)) + _
FORMAT$(st.wMonth,"00") + _
FORMAT$(st.wDay,"00") + _
FORMAT$(st.wHour,"00") + _
FORMAT$(st.wMinute,"00") + _
FORMAT$(st.wSecond,"00") + "." + _
FORMAT$(st.wMilliseconds, "000")
END FUNCTION
FUNCTION PBMAIN
LOCAL TimeString AS STRING
TimeString = TimeStamp
MSGBOX TimeString, 48,"TimeString outside Function TimeStamp"
'I was hoping to display a string showing 30 days later than today
'but I get a date back in 1601 so my attempt to convert the c code
'is not correct.
END FUNCTION
Comment