Page 2 of 2
Posted: Sat Nov 18, 2006 8:34 am
by Antonio Linares
This is the implementation:
Code: Select all | Expand
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( FILETIMETODATE ) // cFileTime --> dDate
{
SYSTEMTIME st;
FileTimeToSystemTime( ( FILETIME * ) hb_parc( 1 ), &st );
hb_retd( st.wYear, st.wMonth, st.wDay );
}
#pragma ENDDUMP
Posted: Sat Nov 18, 2006 8:37 am
by Antonio Linares
This is a sample of use (using your bytes):
Code: Select all | Expand
function Main()
MsgInfo( FileTimeToDate( Chr( 0 ) + Chr( 46 ) + Chr( 46 ) + Chr( 201 ) + ;
Chr( 78 ) + Chr( 240 ) + Chr( 198 ) + Chr( 1 ) ) )
return nil
The shown date is 10/15/06 which it is correct
We are going to modify Class TFtp to automatically use this function.
Posted: Sat Nov 18, 2006 8:47 am
by John
Antonio,
looks great! How can i implement this?
Or shall i wait for your modifications and test them here?
Regards,
John.
Posted: Sat Nov 18, 2006 8:51 am
by Antonio Linares
To get the time a similar function is needed:
Code: Select all | Expand
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( FILETIMETOTIME )
{
SYSTEMTIME st;
char * buffer[ 5 ];
FileTimeToSystemTime( ( FILETIME * ) hb_parc( 1 ), &st );
wsprintf( buffer, "%i:%i", st.wHour, st.wMinute );
hb_retclen( buffer, 5 );
}
#pragma ENDDUMP
Posted: Sat Nov 18, 2006 8:53 am
by Antonio Linares
This is the final code for Class TFtp:
Code: Select all | Expand
if ! Empty( oWin32FindData:cFileName )
AAdd( aFiles, { oWin32FindData:cFileName,;
oWin32FindData:nSizeLow,;
FileTimeToDate( oWin32FindData:nLastWriteAccess ),;
FileTimeToTime( oWin32FindData:nLastWriteAccess ) } )
while InternetFindNextFile( hFTPDir, @cBuffer )
oWin32FindData:cBuffer = cBuffer
AAdd( aFiles, { oWin32FindData:cFileName,;
oWin32FindData:nSizeLow,;
FileTimeToDate( oWin32FindData:nLastWriteAccess ),;
FileTimeToTime( oWin32FindData:nLastWriteAccess ) } )
end
endif
Posted: Sat Nov 18, 2006 10:10 am
by John
Antonio,
when adding the two implementations and the code i get this compiling message:
Warning W8075 TFTP.PRG 151: Suspicious pointer conversion in function HB_FUN_FIL ETIMETOTIME
Warning W8075 TFTP.PRG 153: Suspicious pointer conversion in function HB_FUN_FIL ETIMETOTIME
it refers to this:
wsprintf( buffer, "%i:%i", st.wHour, st.wMinute );
hb_retclen( buffer, 5 );
The date is returned fine, the time returns 3:8 instead of 3:08
Regards,
John.
Posted: Sat Nov 18, 2006 10:45 am
by Antonio Linares
John,
This is wrong:
char * buffer[ 5 ];
It should be:
char buffer[ 5 ];
Also, we need to change "%i:%i" in order to get two digits format for each value. We are searching for the right format.
Posted: Sat Nov 18, 2006 10:48 am
by Antonio Linares
This is the right mask:
"%02i:%02i"
Posted: Sat Nov 18, 2006 1:39 pm
by John
Antonio,
That solved the problem!
I've tested the results but the time 14:58 gets interpreted as 08:58. Also the seconds seem to be missing?
Best regards,
John.
Posted: Sat Nov 18, 2006 3:39 pm
by Antonio Linares
John,
Try this one:
Code: Select all | Expand
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( FILETIMETOTIME )
{
SYSTEMTIME st;
char buffer[ 9 ];
FileTimeToSystemTime( ( FILETIME * ) hb_parc( 1 ), &st );
wsprintf( buffer, "%02i:%02i:%02i", st.wHour, st.wMinute, st.wSecond );
hb_retclen( buffer, 8 );
}
#pragma ENDDUMP
Posted: Sat Nov 18, 2006 4:48 pm
by John
Hi Antonio,
everything seems to work fine now, thanks! Will this be implemented in one of the next releases?
Saludos,
John.
Posted: Sun Nov 19, 2006 8:11 am
by Antonio Linares
John,
> Will this be implemented in one of the next releases?
yes