SetFTime() conversion error

SetFTime() conversion error

Postby Badara Thiam » Sun Sep 28, 2008 9:12 pm

Hello,

I am testing a xHarbour with FWH 8.6 application.
SetFTime() have a problem to return the time required :

*******************************************************
CLIPPER :

With Fivewin for Clipper , it make the time, but the seconds passed
to SetFTime() are not the seconds given to SetFTime() :

SetFTime( nIdent, "10:10:10", Date()) gives seconds * 2

file time is then "10:10:20".
*******************************************************
xHARBOUR :

With Fivewin for xHarbour , the hours and the seconds passed
to SetFTime() are not these given to SetFTime() :

SetFTime( nIdent, "10:10:10", Date()) gives hours + 2 and seconds - 2

file time is then "12:10:08".
*******************************************************
Tested with date franch format (DD/MM/YYYY)

Regards,
Badara Thiam
http://www.icim.fr
User avatar
Badara Thiam
 
Posts: 160
Joined: Tue Oct 18, 2005 10:21 am
Location: France

Postby Antonio Linares » Mon Sep 29, 2008 7:33 am

Badara,

The C conversion funtions that we use seem to be ok, so the error has to be in the Windows API (?)

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

function Main()

   local aTime := Test( "10:11:12" )

   MsgInfo( aTime[ 1 ] )
   MsgInfo( aTime[ 2 ] )
   MsgInfo( aTime[ 3 ] )

return nil

#pragma BEGINDUMP

#include <hbapi.h>

static unsigned int CharsToWord( char * pChars )
{
   unsigned int w = 0;

   if( pChars[ 0 ] != '0' )
      w = ( pChars[ 0 ] - '0' ) * 10;

   if( pChars[ 1 ] != '0' )
      w += ( pChars[ 1 ] - '0' );

   return w;
}

HB_FUNC( TEST )
{
   char * pTime = hb_parc( 1 );
   
   hb_reta( 3 );

   hb_stornl( CharsToWord( pTime ),     -1, 1 );
   hb_stornl( CharsToWord( pTime + 3 ), -1, 2 );
   hb_stornl( CharsToWord( pTime + 6 ), -1, 3 );
}   

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Badara Thiam » Mon Sep 29, 2008 9:15 am

Antonio,

After others tests i see that the seconds
in leee, with xHarbour, is not the fact of
SetFTime() but of Directory().
The hours in more is the fact of SetFTime().

Test please with hour between 0 and 1:59
like this :

- SetFTime(nIdent, "01:00:00", Date())
or
- Hour between 22:01 and 23:59
for the file time before use SetFTime()


I will test today on other PC on XP.
Yesterday it was on Vista Homel Premium.

Regards,
Badara Thiam
http://www.icim.fr
User avatar
Badara Thiam
 
Posts: 160
Joined: Tue Oct 18, 2005 10:21 am
Location: France

Postby Badara Thiam » Wed Nov 05, 2008 8:19 pm

Antonio,

The function SetFTime() have a vicious error !!!

She write the Date/time of GMT time, not local date/time
passed in parameters.

The difference is not 2 hours now, but 1 hour,
since the french time is in Winter time...

Regards.
Badara Thiam
http://www.icim.fr
User avatar
Badara Thiam
 
Posts: 160
Joined: Tue Oct 18, 2005 10:21 am
Location: France

Re: SetFTime() conversion error

Postby Badara Thiam » Wed Apr 01, 2009 9:03 am

Hello,

There is always a problem with SETFTIME() and SETFDATI() for [x]Harbour.
The date and time writted are not local date and time but GMT time.
In France there is different time in summer than in Winter.
This bug is a big problem for network. It is not possible to forget it...

Has someone solved this ?

Best regards.
Badara Thiam
http://www.icim.fr
User avatar
Badara Thiam
 
Posts: 160
Joined: Tue Oct 18, 2005 10:21 am
Location: France

Re: SetFTime() conversion error

Postby Badara Thiam » Wed Apr 01, 2009 3:14 pm

I think i have found the problem, it was in my code.
I used DTOS() to pass the date parameter to SetFTime()
and you know the result...

Sorry, forget my last post please.

Best Regards.
Badara Thiam
http://www.icim.fr
User avatar
Badara Thiam
 
Posts: 160
Joined: Tue Oct 18, 2005 10:21 am
Location: France

Re: SetFTime() conversion error

Postby Davide » Sat Mar 05, 2011 2:17 am

Dear Badara,
Badara Thiam wrote:I think i have found the problem, it was in my code.
I used DTOS() to pass the date parameter to SetFTime()

I too have have the problem that the Time is GMT, so it's different when you look at the file with DIRECTORY (or just with a DIR from the Command Prompt)

Could you please explain me how you did solve it ?

Thanks,
Davide
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Re: SetFTime() conversion error

Postby Badara Thiam » Sat Mar 05, 2011 12:47 pm

Hello

See below the actual state of my function SETFDATI(). You can see here where was the problem.
I don't give functions used in SETFDATI() like HEURES() who give the space time between two times in "C" type,
and HEURESADD() who add hours, minutes and seconds in "C" type also.

Regards

Code: Select all  Expand view  RUN


*****************
FUNCTION SETFDATI(CFIC, QDATE, QHEURE)
*****************
* Enregistrement de la date et l'heure d'un fichier quelconque

LOCAL nDatePlus := 0
LOCAL cHeureDiff := "00:00:00"

LOCAL nATTRIB
LOCAL nIDENT
LOCAL nHeures
LOCAL nMinutes
LOCAL nSecondes
LOCAL dFDate := FILEDATE( CFIC )
LOCAL hFHeure := FILETIME( CFIC )
LOCAL HeureCalc

IF dFDate = QDATE .AND. hFHeure = QHEURE
  * Ok : rien à faire
  RETURN NIL
ENDIF

nATTRIB := FILEATTR( CFIC )
IF nATTRIB > 0
  SETFATTR(CFIC, 0)
ENDIF
nIDENT := FOPEN( CFIC, 18 )
IF nIDENT >= 0
  IF ISCLIPPER()

    SetFTime( nIDENT, LEFT(QHEURE,6) + PADL( INT( VAL( SUBSTR(QHEURE,7,2) ) / 2), 2, "0") , ;
    QDATE )

    FCLOSE( nIDENT )

  ELSE

    SetFTime( nIDENT, QHEURE, QDATE )

    dFDate := FILEDATE( CFIC )
    hFHeure := FILETIME( CFIC )

    FCLOSE( nIDENT )

    IF dFDate != QDATE .OR. hFHeure != QHEURE
    /* Si SetFTime() n'a pas affecté les bonnes date et heure au fichier (décalage temps GMT avec FWH86 ! ) */

      IF dFDate > QDATE
        nDatePlus := 1
      ELSEIF dFDate < QDATE
        nDatePlus := -1
      ELSE
        nDatePlus := 0
      ENDIF

      IF nDatePlus > 0
      * Si la date du fichier est supérieure à celle voulue !
        cHeureDiff := "-" + HEURES(QHEURE, hFHeure)
      ELSEIF nDatePlus < 0
        cHeureDiff := HEURES(hFHeure, QHEURE)
      ELSEIF QHEURE < hFHeure
        cHeureDiff := "-" + HEURES(QHEURE, hFHeure)
      ELSEIF QHEURE > hFHeure
        cHeureDiff := HEURES(hFHeure, QHEURE)
      ELSE
        cHeureDiff := "00:00:00"
      ENDIF

      nIDENT := FOPEN( CFIC, 18 )
      IF nIDENT >= 0

        HeureCalc := SETFDATIH(QHEURE, cHeureDiff, @QDATE)

        SetFTime( nIDENT, HeureCalc, DTOS( QDATE ) )
        FCLOSE( nIDENT )

      ENDIF
    ENDIF

  ENDIF

ENDIF
IF nATTRIB > 0
  SETFATTR(CFIC, nATTRIB)
ENDIF
RETURN NIL

 


Code: Select all  Expand view  RUN

******************
FUNCTION SETFDATIH(QHEURE, cHeureDiff, QDATE)
******************
LOCAL cHeureNouv := LTRIM( HEURESADD( QHEURE, cHeureDiff ) )
IF LEFT(cHeureNouv,1) = "-"
  cHeureNouv := LTRIM( HEURESADD( "24:00:00", cHeureNouv ) )
  QDATE := QDATE - 1
ELSEIF VAL( LEFT(cHeureNouv, AT(":", cHeureNouv) -1 ) ) >= 24
  cHeureNouv := LTRIM( HEURESADD( "-24:00:00", cHeureNouv ) )
  QDATE := QDATE + 1
ENDIF
cHeureNouv := PADL(cHeureNouv, 8, "0")
RETURN cHeureNouv


 
Badara Thiam
http://www.icim.fr
User avatar
Badara Thiam
 
Posts: 160
Joined: Tue Oct 18, 2005 10:21 am
Location: France

Re: SetFTime() conversion error

Postby Davide » Sat Mar 05, 2011 1:14 pm

Dear Badara,
Badara Thiam wrote:See below the actual state of my function SETFDATI(). You can see here where was the problem.

thank you.
I finally found out that GetFTime() retrieves the same date/time of SetFTime(), so I solved my problem that way.
To retrieve the difference in hours (GMT+/-) you can just compare the result of Directory() with GetFTime()

Thanks again,
Davide
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 67 guests