With
Habour is compiled but then not show any times and the exe is on memoty of Pc
With xharbour give me also errors Code: Select all | Expand
Progetto:
InternetDate, Ambiente:
xFive_Pelles:
[1]:
Harbour.Exe test.prg /m /n0 /gc1 /w0 /es2 /iC:\Work\fwh\include /ic:\work\xHarbour\Include /jC:\Work\Prg\SOFTWA~
1\INTERN~
1\I18n\Main.hil /iinclude;c:\work\fwh\include;c:\work\xHarbour\include /oObj\test.c
xHarbour
1.2.3 Intl.
(SimpLex
) (Build
20140725)Copyright
1999-2014, http:
//www.xharbour.org http://www.harbour-project.org/Compiling
'test.prg'...
Generating international list
to 'C:\Work\Prg\SOFTWA~1\INTERN~1\I18n\Main.hil'...
Generating C source output
to 'Obj\test.c'...
Done.
Lines
98, Functions/Procedures
5, pCodes
276[1]:
Bcc32.Exe -M -c -O2 -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\work\xHarbour\Include -nC:\Work\Prg\SOFTWA~
1\INTERN~
1\Obj test.c
Borland C++
5.82 for Win32 Copyright
(c
) 1993,
2005 Borland
test.c:
[1]:
iLink32.Exe -Gn -aa -Tpe -s @InternetDate.bcl
Turbo Incremental Link
5.69 Copyright
(c
) 1997-2005 Borland
[b
]Error:
Unresolved external
'_HB_FUN_HB_UTCOFFSET' referenced
from C:\WORK\PRG\SOFTWARELOCK_OF_JEFF\INTERNETDATE\OBJ\TEST.OBJ
Error:
Unresolved external
'WSAIoctl' referenced
from C:\WORK\XHARBOUR\LIB\RTL.LIB|hbsocket
Error:
Unresolved external
'_HB_FUN_HB_BCHAR' referenced
from C:\WORK\PRG\SOFTWARELOCK_OF_JEFF\INTERNETDATE\OBJ\TEST.OBJ
Error:
Unresolved external
'_HB_FUN_HB_VERSION' referenced
from C:\WORK\PRG\SOFTWARELOCK_OF_JEFF\INTERNETDATE\OBJ\TEST.OBJ
[/b
]
the ultimate script
Code: Select all | Expand
#include "FiveWin.ch"
#include "hbsocket.ch"
#include "hbver.ch"
#include "hbcompat.ch"
#Include "xbrowse.ch"
*------------------------------------------*
Function Main()
*------------------------------------------*
xBrowser GetDateTimeFromNTP()
Return
*------------------------------------------*
Function GetDateTimeFromNTP()
*------------------------------------------*
/* This function would return the Real date and time from an internet date time server via NTP.
If successful, Returns an array containing 3 elements ie GMT DateTime, Indian Standarrd Date Time, PC's Date Time
If not successful then returns an empty array.
This function depends on the the other 3 functions like hb_ntp_GetTimeUTC(),ntohl(),Bin2U()
All these functions are available in the Harbour lib HbMisc.
Unfortunately, the day that we made this function ie 29-Apr-2014, these functions were not included in the HbMisc supplied along
with FWH. So next time when we get an updated Harbour ver with FWH, we can eliminate the functions
hb_ntp_GetTimeUTC(),ntohl(),Bin2U() from this PRG. Till then it is required
*/
LOCAL tGmtDateTime,tPcDateTime,aDateTime:={}
TRY
tGmtDateTime := hb_ntp_GetTimeUTC( "0.europe.pool.ntp.org" )
CATCH
Return aDateTime:={}
END
tPcDateTime:=hb_DateTime()
aAdd(aDateTime,tGmtDateTime) // UTC ie GMT Date Time
aAdd(aDateTime,tGmtDateTime + hb_UTCOffset() / 86400) // Converted to IST
aAdd(aDateTime,tPcDateTime) // The date time in PC
* xbrowser aDateTime
/*
MsgInfo("UTC Time : "+Ttoc(tTime)+CRLF+;
"Local Time : "+Ttoc(tTime + hb_UTCOffset() / 86400) +CRLF+; //86400
"Sytem Time : "+Ttoc(hb_DateTime() ) )
*/
RETURN aDateTime
*-------------------------------------------------------*
FUNCTION hb_ntp_GetTimeUTC( cServer, nPort, nTimeOut )
*-------------------------------------------------------*
LOCAL tTime := hb_SToT( "" )
LOCAL hSocket, cBuffer
* DEFAULT nPort:=123
* DEFAULT nTimeOut:=10000 // 10seconds
IF HB_ISSTRING( cServer ) .AND. ! Empty( cServer ) .AND. ;
! Empty( hSocket := hb_socketOpen( , HB_SOCKET_PT_DGRAM ) )
cBuffer := hb_BChar( 8 ) + Replicate( hb_BChar( 0 ), 47 )
IF hb_socketSendTo( hSocket, cBuffer,,, { HB_SOCKET_AF_INET, hb_socketResolveAddr( cServer ), nPort } ) == hb_BLen( cBuffer )
cBuffer := Space( 12 * 4 )
IF hb_socketRecvFrom( hSocket, @cBuffer,,,, nTimeOut ) == hb_BLen( cBuffer )
tTime := hb_SToT( "19000101" ) + ;
Bin2U( ntohl( hb_BSubStr( cBuffer, 10 * 4 + 1, 4 ) ) ) / 86400 + ;
( Bin2U( ntohl( hb_BSubStr( cBuffer, 11 * 4 + 1, 4 ) ) ) / ( 2 ^ 32 ) ) / 86400
ENDIF
ENDIF
hb_socketClose( hSocket )
ENDIF
RETURN tTime
*---------------------------*
STATIC FUNCTION ntohl( c )
*---------------------------*
IF hb_Version( HB_VERSION_ENDIANNESS ) == HB_VERSION_ENDIAN_LITTLE
RETURN ;
hb_BSubStr( c, 4, 1 ) + ;
hb_BSubStr( c, 3, 1 ) + ;
hb_BSubStr( c, 2, 1 ) + ;
hb_BSubStr( c, 1, 1 )
ENDIF
RETURN c
*---------------------------*
STATIC FUNCTION Bin2U( c )
*---------------------------*
LOCAL l := Bin2L( c )
RETURN iif( l < 0, l + ( 2 ^ 32 ), l )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com