FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Java GetTime Function
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Java GetTime Function
Posted: Fri Dec 06, 2024 06:40 PM

Hi Guys,

Do you know if is there in Harbour/Fivewin any function like GetTime() from Java ?

Or

How could I convert a Date to a double value?

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Java GetTime Function
Posted: Fri Dec 06, 2024 07:56 PM
Hola, Algo asi?
Code (fw): Select all Collapse
// https://pt.stackoverflow.com/questions/494387/como-formatar-uma-data-no-harbour

#Include "FiveWin.ch"

FUNCTION Main()

   SET CENTURY ON
   SET DATE BRITISH
   SET TIME FORMAT TO "HH:MM:SS"
   SET EPOCH TO YEAR( DATE() ) - 30
   SET SOFTSEEK OFF
   SET WRAP ON
   SETCANCEL( .F. )
   SET CONFIRM OFF
   SET DELETED ON
   SET _3DLOOK ON
   SET UNIQUE OFF
   SET ESCAPE OFF
   SET EXACT ON       // CONTROLA O :=, = e ==
   SET EXCLUSIVE OFF
   SET MULTIPLE OFF
   SET OPTIMIZE ON 

   ? hb_Dtoc( Date(), "YYYY-MM-DD" )

   ? hb_Dtoc( Date(), "DD-MM-YYYY" )

   ? hb_Dtoc( Date(), "MMDDYY"     )

   ? hb_Dtoc( Date(), "DDMMYY"     )

RETURN NIL

FUNCTION hb_Dtoc( dData, dFormat )

   IF dFormat == NIL

      RETURN Dtoc( dData )

   ENDIF

   dFormat := Upper( dFormat )
   dFormat := StrTran( dFormat, "DD",   StrZero( Day( dData ), 2 ) )
   dFormat := StrTran( dFormat, "MM",   StrZero( Month( dData ), 2 ) )
   dFormat := StrTran( dFormat, "YYYY", StrZero( Year( dData ), 4 ) )
   dFormat := StrTran( dFormat, "YY",   StrZero( Mod( Year( dData ), 100 ), 2 ) )

RETURN( dFormat )

// FIN / END
https://www.google.com/search?q=converter+uma+data+em+um+valor+duplo+harbour&oq=converter+uma+data+em+um+valor+duplo+harbour&aqs=chrome..69i57j33i160l2.5227j0j15&sourceid=chrome&ie=UTF-8

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Java GetTime Function
Posted: Sat Dec 07, 2024 08:14 PM
How could I convert a Date to a double value?
? HB_DateTime() - STOT("")
Regards



G. N. Rao.

Hyderabad, India
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Java GetTime Function
Posted: Mon Dec 09, 2024 10:42 AM
Mr Rao,

When i tried HB_DateTime() - STOT("") the function i called is receiving this date 14/01/8637
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Java GetTime Function
Posted: Mon Dec 09, 2024 02:01 PM
Please explain your actual requirement.
Code (fw): Select all Collapse
? HB_DateTime() // --> 2024-12-09 19:29:45
This is a DateTime value ( valtype "T" )
Regards



G. N. Rao.

Hyderabad, India
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Java GetTime Function
Posted: Mon Dec 09, 2024 02:09 PM
I need to call this function:

PIXCD_ConsultarPixRecebidos(ADataInicio, ADataFim, ATxId, ACpfCnpj, PagAtual, ItensPorPagina, sResposta, esTamanho)

Where aDataInic and aDataFim are from DATE type. That i've declared by this way:

DLL32 FUNCTION PIXCD_ConsultarPixRecebidos(ADataInicio AS _DOUBLE,ADataFim AS _DOUBLE,ATxId AS STRING,;
ACpfCnpj AS STRING, PagAtual AS _INT, ItensPorPagina AS _INT,;
@sResposta AS STRING,@nTamanho AS _INT) AS LONG PASCAL FROM "PIXCD_ConsultarPixRecebidos" LIB oACPx
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Java GetTime Function
Posted: Mon Dec 09, 2024 02:35 PM

Do you propose to use

days.fraction of day

as double?

Hope you made sure in which format that software expects the date-time values.

Another most important thing is what is the Epoch date. This differs from software to software.

Microsoft' Ole sources count date/time from epoch Jan 1, 1900 00 hours

Unix / java/ etc start with Jan 1 1970 00 hours

FW_DateToUnix( tHarbourDateTime ) --> nMilliSeconds ( Unixtime )

The value we provide depends on what the other library actually expects

Regards



G. N. Rao.

Hyderabad, India
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Java GetTime Function
Posted: Mon Dec 09, 2024 05:50 PM
Thank you,
It worked with FW_DateToUnix() ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil

Continue the discussion