FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour ¿Cómo saber la fecha de los cambios a una carpeta?
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
¿Cómo saber la fecha de los cambios a una carpeta?
Posted: Sat Mar 02, 2024 07:02 PM

Amigos,

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

¿Hay alguna manera?

"Los errores en programación, siempre están entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: ¿Cómo saber la fecha de los cambios a una carpeta?
Posted: Sun Mar 03, 2024 08:33 AM
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 (fw): Select all Collapse
#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: ¿Cómo saber la fecha de los cambios a una carpeta?
Posted: Sun Mar 03, 2024 09:09 AM
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 (fw): Select all Collapse
#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.
"Los errores en programación, siempre están entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: ¿Cómo saber la fecha de los cambios a una carpeta?
Posted: Mon Mar 04, 2024 02:38 PM
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 (fw): Select all Collapse
#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?
"Los errores en programación, siempre están entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ¿Cómo saber la fecha de los cambios a una carpeta?
Posted: Mon Mar 04, 2024 05:09 PM
There is another way:
Code (fw): Select all Collapse
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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ¿Cómo saber la fecha de los cambios a una carpeta?
Posted: Mon Mar 04, 2024 05:21 PM
Time Zone conversions
Here is an example converting our local time to UTC and then NewYork time ( UTC Offset now -5:00 )
Code (fw): Select all Collapse
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
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ¿Cómo saber la fecha de los cambios a una carpeta?
Posted: Mon Mar 04, 2024 05:27 PM
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 (fw): Select all Collapse
tsUTC := FW_AddTime( DateTimeSpain. "-01:00:00" )
tsIndia := FW_AddTime( tsUTC, "05:30:00" )
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion