Page 1 of 1

Get SNTP Server Time and Set LocalTime

Posted: Fri Oct 13, 2006 2:01 pm
by ssbbs
The Library is compile use BCC5 for xHarbour and Fivewin(free).

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

Code: Select all

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