|
-
Dec 5th, 1999, 08:03 PM
#1
Thread Starter
Lively Member
does anyone know how to retrieve time from the internet atomic clock?
--michael
-
Dec 6th, 1999, 04:56 PM
#2
PowerPoster
what is the internet's atomic clock?? I've never heard of it...
-
Dec 9th, 1999, 03:21 AM
#3
Thread Starter
Lively Member
it's the government's clock that uses atoms (somehow) to tell time. it is accurate to something like a billionth of a second. i have seen programs that connect to it to retrieve and set the time for their own computer. but since i am writing a clock program i just thought it might be a nice little added feature to add the ability to retrieve the "perfect atomic time" that's all.
--michael
-
Dec 9th, 1999, 04:20 AM
#4
Hyperactive Member
Just a little note in case anyone is wondering. The atomic clock works by measuring the oscillations of certain elements like Cesium and Hydrogen. These clocks are accurate to about 1 second in a million years. One site you could check out is:
http://www.cstv.to.cnr.it/toi/uk/atomtime.html
------------------
Ryan
[email protected]
ICQ# 47799046
-
Dec 9th, 1999, 11:43 AM
#5
Lively Member
http://www.eecis.udel.edu/~ntp/software.html
tycho.usno.navy.mil
look at this pages
the first have some programs to retrive the time from the atomic clock
-
Dec 9th, 1999, 12:26 PM
#6
Lively Member
http://www.mhn.org/~graham/nettime.html
here are a code in c++ that do what you want
-
Dec 9th, 1999, 11:43 PM
#7
Ok, I think I figured it out.
Draw a winsock control and a command button on a form, and paste the code. It will synchronize your system time with the atom clock of the nist institute.
Code:
Option Explicit
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Sub GetTime()
Dim TimeOut As Boolean
Dim StartTime As Single
TimeOut = False
StartTime = Timer
Winsock1.RemoteHost = "time.nist.gov"
Winsock1.RemotePort = 13
Winsock1.Connect
While (Not Winsock1.State = 7) Or TimeOut
DoEvents
TimeOut = Timer > StartTime + 5
Wend
End Sub
Private Sub Command1_Click()
Call GetTime
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData, vbString
Call SetTime(strData)
Winsock1.Close
Winsock1.LocalPort = 0
Unload Me
End Sub
Private Sub SetTime(ByVal TimeString As String)
Dim RetVal As Long
Dim udtTime As SYSTEMTIME
Dim TempDate As Date
If Val(Mid(TimeString, 31, 1)) < 2 Then 'server is healthy enough
TempDate = CDate(Val(Mid(TimeString, 2, 5)) - 15018)
With udtTime
.wYear = Year(TempDate)
.wDayOfWeek = 0
.wMonth = Month(TempDate)
.wDay = Day(TempDate)
.wHour = Val(Mid(TimeString, 17, 2))
.wMinute = Val(Mid(TimeString, 20, 2))
.wSecond = Val(Mid(TimeString, 23, 2))
.wMilliseconds = 0
End With
RetVal = SetSystemTime(udtTime)
End If
End Sub
-
Dec 10th, 1999, 08:58 AM
#8
Hyperactive Member
Just a silly question. Those atomic clocks are impressively accurate,
but are there not huge delays in the net that you can not control?
I used Tracert (in a DOS window) and noticed delays of several seconds.
Don't those delays add to the retrieved time?
[This message has been edited by Juan Carlos Rey (edited 12-10-1999).]
-
Dec 10th, 1999, 11:25 PM
#9
The Nist institute adds a certain time to compensate for network delays. But I'm sure the accuracy isn't the same as the clock itselve. However, I noticed the connection doesn't take seconds but just a second at the most. (the Netherlands to the US and back)
[This message has been edited by Frans C (edited 12-11-1999).]
-
Dec 11th, 1999, 04:57 PM
#10
Thread Starter
Lively Member
damn Frans C...you are the man!! thank you so much. i have been trying to do this for a while now and kept screwing it up when it came to passing the retrieved time to my system's clock. thanks so very much for figuring this one out for me. liek i said...you are the man!!!
--michael
-
Dec 11th, 1999, 08:50 PM
#11
Actually, I used the AtomTime98 program to match my computer clock with the atomic clock and It is almsot exact. If I look at my cable box my computer clock is about 1/2 a second differnt.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|