Page 1 of 1

Java GetTime Function

Posted: Fri Dec 06, 2024 6:40 pm
by vilian
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?

Re: Java GetTime Function

Posted: Fri Dec 06, 2024 7:56 pm
by karinha
Hola, Algo asi?

Code: Select all | Expand

// 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=convert ... e&ie=UTF-8

Regards, saludos.

Re: Java GetTime Function

Posted: Sat Dec 07, 2024 8:14 pm
by nageswaragunupudi
How could I convert a Date to a double value?
? HB_DateTime() - STOT("")

Re: Java GetTime Function

Posted: Mon Dec 09, 2024 10:42 am
by vilian
Mr Rao,

When i tried HB_DateTime() - STOT("") the function i called is receiving this date 14/01/8637

Re: Java GetTime Function

Posted: Mon Dec 09, 2024 2:01 pm
by nageswaragunupudi
Please explain your actual requirement.

Code: Select all | Expand

? HB_DateTime() // --> 2024-12-09 19:29:45
This is a DateTime value ( valtype "T" )

Re: Java GetTime Function

Posted: Mon Dec 09, 2024 2:09 pm
by vilian
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

Re: Java GetTime Function

Posted: Mon Dec 09, 2024 2:35 pm
by nageswaragunupudi
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

Re: Java GetTime Function

Posted: Mon Dec 09, 2024 5:50 pm
by vilian
Thank you,
It worked with FW_DateToUnix() ;)