FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Get SNTP Server Time and Set LocalTime
Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Get SNTP Server Time and Set LocalTime
Posted: Fri Oct 13, 2006 02:01 PM
The Library is compile use BCC5 for xHarbour and Fivewin(free).

link://www4.zzz.com.tw/phpbb2/viewtopic.php?t=29

Func    Test()
Local   aNet      := {},;
        nPort     := 123,;
        cIp       := "time.windows.com",;
        lSync     := .T.,;
        oSntp     := NIL

        ? "test begin"

        // test-1
        // lSync = .T., Set LocalTime same as NTP Server time
         oSntp := TSntp():New( cIP, nPort, lSync )
        // or oSntp := TSntp():New(); oSntp:cIp := '....'; oSntp:nPort = ....
        If oSntp:GetData()
           ? oSntp:Date(), "date"
           ? oSntp:Time(), "time"
           ? oSntp:nWeek, "Week"
           ? oSntp:nDayOfYear, "Day Of Year"
        Else
           ? "Fail"
        EndIf

        // test-2
        If oSntp:GetData()
           ? oSntp:Date(), "date"
           ? oSntp:Time(), "time"
        Else
           ? "Fail"
        EndIf

        ? "test end"

Return  NIL
line ID: ssbbstw

WeChat ID: ssbbstw

Continue the discussion