Page 1 of 1

¿Cómo saber la fecha de los cambios a una carpeta?

PostPosted: Sat Mar 02, 2024 7:02 pm
by JoseAlvarez
Amigos,

Necesito saber la ultima fecha en la que una carpeta de windows tuvo cambios.

¿Hay alguna manera?

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

PostPosted: Sun Mar 03, 2024 8:33 am
by Antonio Linares
Estimado José,

Aquí lo tienes. Lo incluimos para el próximo build de FWH:

function FW_FolderChanged( cFolderPath ) --> { nDay, nMonth, nYear, nHours, nMinutes, nSeconds }

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    XBrowse( FW_FolderChanged( "c:\fwh" ) )

return nil

#pragma BEGINDUMP

#include <Windows.h>
#include <hbapi.h>

HB_FUNC( FW_FOLDERCHANGED )
{
   const char * folderPath = hb_parc( 1 );
   FILETIME lastWriteTime;
   WIN32_FILE_ATTRIBUTE_DATA fileAttributes;
   SYSTEMTIME systemTime;

   GetFileAttributesEx( folderPath, GetFileExInfoStandard, &fileAttributes );
   lastWriteTime = fileAttributes.ftLastWriteTime;
   FileTimeToSystemTime(&lastWriteTime, &systemTime);

   hb_reta( 6 );
   hb_storvnl( systemTime.wDay, -1, 1 );
   hb_storvnl( systemTime.wMonth, -1, 2 );
   hb_storvnl( systemTime.wYear, -1, 3 );
   hb_storvnl( systemTime.wHour, -1, 4 );
   hb_storvnl( systemTime.wMinute, -1, 5 );
   hb_storvnl( systemTime.wSecond, -1, 6 );
}

#pragma ENDDUMP

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

PostPosted: Sun Mar 03, 2024 9:09 am
by JoseAlvarez
Antonio Linares wrote:Estimado José,

Aquí lo tienes. Lo incluimos para el próximo build de FWH:

function FW_FolderChanged( cFolderPath ) --> { nDay, nMonth, nYear, nHours, nMinutes, nSeconds }

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    XBrowse( FW_FolderChanged( "c:\fwh" ) )

return nil

#pragma BEGINDUMP

#include <Windows.h>
#include <hbapi.h>

HB_FUNC( FW_FOLDERCHANGED )
{
   const char * folderPath = hb_parc( 1 );
   FILETIME lastWriteTime;
   WIN32_FILE_ATTRIBUTE_DATA fileAttributes;
   SYSTEMTIME systemTime;

   GetFileAttributesEx( folderPath, GetFileExInfoStandard, &fileAttributes );
   lastWriteTime = fileAttributes.ftLastWriteTime;
   FileTimeToSystemTime(&lastWriteTime, &systemTime);

   hb_reta( 6 );
   hb_storvnl( systemTime.wDay, -1, 1 );
   hb_storvnl( systemTime.wMonth, -1, 2 );
   hb_storvnl( systemTime.wYear, -1, 3 );
   hb_storvnl( systemTime.wHour, -1, 4 );
   hb_storvnl( systemTime.wMinute, -1, 5 );
   hb_storvnl( systemTime.wSecond, -1, 6 );
}

#pragma ENDDUMP


Muchas Gracias Master, le daré un vistazo y estaré comentando.

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

PostPosted: Mon Mar 04, 2024 2:38 pm
by JoseAlvarez
Antonio Linares wrote:Estimado José,

Aquí lo tienes. Lo incluimos para el próximo build de FWH:

function FW_FolderChanged( cFolderPath ) --> { nDay, nMonth, nYear, nHours, nMinutes, nSeconds }

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    XBrowse( FW_FolderChanged( "c:\fwh" ) )

return nil

#pragma BEGINDUMP

#include <Windows.h>
#include <hbapi.h>

HB_FUNC( FW_FOLDERCHANGED )
{
   const char * folderPath = hb_parc( 1 );
   FILETIME lastWriteTime;
   WIN32_FILE_ATTRIBUTE_DATA fileAttributes;
   SYSTEMTIME systemTime;

   GetFileAttributesEx( folderPath, GetFileExInfoStandard, &fileAttributes );
   lastWriteTime = fileAttributes.ftLastWriteTime;
   FileTimeToSystemTime(&lastWriteTime, &systemTime);

   hb_reta( 6 );
   hb_storvnl( systemTime.wDay, -1, 1 );
   hb_storvnl( systemTime.wMonth, -1, 2 );
   hb_storvnl( systemTime.wYear, -1, 3 );
   hb_storvnl( systemTime.wHour, -1, 4 );
   hb_storvnl( systemTime.wMinute, -1, 5 );
   hb_storvnl( systemTime.wSecond, -1, 6 );
}

#pragma ENDDUMP


Master Antonio,

Muchas Gracias. Funciona Muy bien, solo necesito resolver un pequeño detalle.
Me da el dato de la hora con la zona horaria de España. En mi caso, son 7 horas mas adelante que mi hora local.

Alguna manera de sincronizarlo con la hora de los demás países?

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

PostPosted: Mon Mar 04, 2024 5:09 pm
by nageswaragunupudi
There is another way:
Code: Select all  Expand view
function FolderInfo()

   local oFs   := CreateObject( "Scripting.FileSystemObject" )
   local oFolder  := oFs:GetFolder( "c:\fwh\samples" )

   ? oFolder:DateCreated, oFolder:DateLastModified, oFolder:DateLastAccessed

return nil


You will get your local times.

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

PostPosted: Mon Mar 04, 2024 5:21 pm
by nageswaragunupudi
Time Zone conversions
Here is an example converting our local time to UTC and then NewYork time ( UTC Offset now -5:00 )

Code: Select all  Expand view
function TimeZoneConversions()

   local tDateTimeLocal, tDateTimeUTC, tDateTimeNYC

   tDateTimeLocal := HB_DateTime()  // current time
   tDateTimeUTC   := UTC_TIMESTAMP( tDateTimeLocal )  // FWH function
   tDateTimeNYC   := FW_ADDTIME( tDateTimeUTC, "-05:00:00" )

   ? tDateTimeLocal, tDateTimeUTC, tDateTimeNYC

return nil
 

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

PostPosted: Mon Mar 04, 2024 5:27 pm
by nageswaragunupudi
Converting time in Spain to my local time in India.
We know the current UTC offset of Spain is +1:00 and India's is +5:30

Code: Select all  Expand view
tsUTC := FW_AddTime( DateTimeSpain. "-01:00:00" )
tsIndia := FW_AddTime( tsUTC, "05:30:00" )