FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour bug en SetFTime, no cambia la HORA
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: bug en SetFTime, no cambia la HORA
Posted: Tue Jun 25, 2013 06:34 PM
ERROR_INVALID_HANDLE
6 (0x6)
The handle is invalid.


http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx

Ya tenemos una pieza m谩s para completar el puzzle :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: bug en SetFTime, no cambia la HORA
Posted: Tue Jun 25, 2013 06:46 PM
Me faltaba crear fecha.prg :-)

Pero ahora GetLastError() devuelve 228 y ese valor no est谩 documentado :-)
http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: bug en SetFTime, no cambia la HORA
Posted: Tue Jun 25, 2013 06:52 PM

Lo anterior no cuenta, era un error mio en las pruebas. Hoy llevo demasiadas horas de ordenador :-)

SetFTime() me devuelve .T. lo que quiere decir que Windows dice que todo ha ido bien, pero... las horas son distintas.

3:14:20 antes

5:14:20 despues

Asi que como se ha comentado, esta bien salvo la diferencia horaria. En mi opini贸n, o es un bug de Windows, o tenemos que indicarle previamente la diferencia horaria de alguna forma.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: bug en SetFTime, no cambia la HORA
Posted: Tue Jun 25, 2013 06:56 PM
En la documentaci贸n de la funci贸n SetFileTime() de Windows se comenta esto:

the GetFileTime function may not return the same file time information set using SetFileTime

Remarks
Not all file systems can record creation and last access times and not all file systems record them in the same manner. For example, on FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). Therefore, the GetFileTime function may not return the same file time information set using SetFileTime. NTFS delays updates to the last access time for a file by up to one hour after the last access.


http://msdn.microsoft.com/en-us/library/windows/desktop/ms724933(v=vs.85).aspx

Adem谩s proporcionan un ejemplo, desde esa misma p谩gina, que voy a revisar ahora
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: bug en SetFTime, no cambia la HORA
Posted: Tue Jun 25, 2013 07:00 PM
El ejemplo de ellos no tiene nada de particular, usa la funci贸n de la misma forma que lo hace FWH:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724205(v=vs.85).aspx

Luego es un comportamiento propio de Windows.

Misterio resuelto :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 593
Joined: Sat May 12, 2007 11:47 AM
Re: bug en SetFTime, no cambia la HORA
Posted: Wed Jun 26, 2013 02:00 PM
Buen d铆a,

Otra vuelta de tuerca.

Para mi caso, y que la hora que le coloco sea la real, cree una funci贸n a la que le paso los datos por referencia:
Code (fw): Select all Collapse
UTCtoARG(@dDate,@cTime)

y los cambia a UTC+3 (horario de Argentina) y es la siguiente:

Code (fw): Select all Collapse
//---------------------------------------------------------------------------------------------------------------

Function UTCtoARG(dDate,cTime) 聽 // le sumo 3 horas para que una funci贸n que la convierte en utc 
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽聽聽 聽 聽 聽// me deje la hora tal cual la necesito. o sea, retorna la
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// hora que llega pero con 3 horas sumadas y obviamente le suma un d铆a
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// si esto es necesario

local nHora:=val(substr(cTime,1,2))+3, cHora:=substr(cTime,1,2)

//msginfo("Entra "+dtoc(dDate)+"---"+ctime)


if nHora>24 聽 聽 // si se da esta condici贸n, la date hay que aumentarle un d铆a
聽聽 聽聽 聽 nHora:=nHora-24
聽 聽 聽 聽 聽 聽 if len( cHora:=alltrim(str(nHora)) ) == 1 聽// para agregarle un cero adelante cuando es la una,
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// las dos, etc
聽 聽聽聽 聽 聽 聽 cHora:="0"+cHora
聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 cTime:=cHora+substr(cTime,3,6)聽 
聽 聽 聽 聽 dDate:=dDate+1
聽 聽 else
聽 聽 聽 聽 
聽 聽 聽 聽 if len( cHora:=alltrim(str(nHora)) ) == 1 聽// para agregarle un cero adelante cuando es la una, 
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //las dos, etc
聽 聽聽聽 聽 聽 聽 cHora:="0"+cHora
聽 聽 聽 聽 endif
聽 聽 聽 聽 cTime:=cHora+substr(cTime,3,6)
endif 

//msginfo("Sale "+dtoc(dDate)+"---"+ctime)

Return nil

//---------------------------------------------------------------------------------------------------------------



Con esto reformo la fecha y hora al horario "real" de Argentina (UTC +3) pero se adapta a cualquier pa铆s con solo cambiarle el nro a sumar (o restar).

Como dice un amigo, "A mi me gusta vivir en Argentina, porque cuando son las doce, son las doce y no las 15 o las 9 como en otros pa铆ses". Je je.

Rolando :-)

Continue the discussion