name
Thu Apr 29 01:34:10 CDT 2004
This is a multi-part message in MIME format.
------=_NextPart_000_0022_01C42D92.73D301A0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: 7bit
I post you my timeHTTP.js which has been working the day xmlHTTP was out.
Think that was little after march 1998.
"It is scheduled and called from within another script at around 4 a.m."
==================
Caveat : It is unedited.
So it is more than you may want. So leave it as is, when you try it.
Has failed this year twice.
May be because I have some 'military server' on it.
On the other hand it was written for accuracy.
May still be within 5 milliseconds.
Some credit goes to Dr. Stockton.
------------------------------
There are a couple of 'few liners" around via [google/wsh/time server]
that may work even better.
Time goes foreward.
==========
If you have a firewall you may need set permission for all :
IE,wsh,hta
=============
Regular Time servers have their own protocol, correspond binary,
are fed e.g. via 5 redundant ceasium clocks, and have the 'NIST' internal
deviation of 50 milliseconds.
Again it was written around 1998, in the wake of javascript and hta
blossoms.
"LoWang" <anonymous@discussions.microsoft.com> wrote in message
news:D5F30EC2-C5F2-4B63-9DFF-E432541161D3@microsoft.com...
> I need to synchronize the system time on the client computer with a server
by the web browser.
> Is it possible to do by some VBScript or is it possible to run such script
in a WSH launched by the web browser?
------=_NextPart_000_0022_01C42D92.73D301A0
Content-Type: text/plain;
name="timeHTTP.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="timeHTTP.txt"
//Smallest Legible Time Adjust Program To Date
//To shorten further use xmlHttp and RegEpr
// Legible Programs, LP-License
=09
function MilliSeconds() { return new Date().getTime() }
=09
var ScriptStartTime =3D MilliSeconds()
var browser
var UTC
var getUTC
var out =3D "";
var header =3D 0
var loading =3D 0
=09
var Step =3D []
var TimeLine =3D []
=09
function tl() { TimeLine[TimeLine.length] =3D new Date().getTime() }
=09
var Type =3D [] =09
var Process =3D [] =09
var Result =3D []
=09
var i =3D 0;
var oShell =3D new ActiveXObject("WScript.Shell")
=09
//WScript.Sleep("2000")
=09
//oShell.Run("notepad.exe",1,false)
//oShell.Run("time.bat",0,false)
=09
=09
function ParsingStatus() {
var state =3D browser.readyState
=09
//ticker.innerHTML +=3D state + "<br>" //+ =
state=3D=3D1?"loading":"interactive" + "<br>"
=09
if(state < 4){
=09
if(state =3D=3D 3){
var process =3D "Parsing"
var result =3D "interactive"
getUTC[process + i++] =3D result ; tl()
=09
TickArrived()
}
else
{
var process =3D "Parsing"
var result =3D "loading"
getUTC[process + i++] =3D result ; tl()
=09
WScript.Sleep("500")
ParsingStatus()
=09
//browser.setTimeout("ParsingStatus()",500)
//browser.setTimeout("ParsingStatus()",500)
}
}
}
=09
function TickArrived()
{
getUTC.RetrievalEnd =3D new Date().getTime() ; tl()
getUTC.PCDateTime =3D new Date().getTime() ; tl()
=09
legible =3D browser.document.all.tags("H2")
=09
//ticker.innerHTML =3D ticker.innerHTML + legible + "<br>"
=09
if(legible) {
UTC =3D browser.document.all.tags("H2")[0].innerText
=09
getUTC.UTC =3D UTC ; tl()
=09
browser.Stop()
//window.close()
browser.Quit()
browser =3D null
=09
oShell =3D null;
=09
convert()
}
else
browser.setTimeout("ParsingStatus()",500)
}
function ThrustObject() {
browser =3D new ActiveXObject("InternetExplorer.Application");
=09
getUTC.HTTPObject =3D "started" ; tl()
=09
browser.Visible =3D false;
//alert(browser.Busy)
browser.Silent =3D true;
//browser.Navigate ("
http://tycho.usno.navy.mil/cgi-bin/anim");
}
function ApplicationObject()
{
this.ScriptStart =3D ScriptStartTime ; tl()
=09
}
=09
function convert()
{
getUTC.UTCgetTime =3D new Date(UTC).getTime() ; tl()
=09
getUTC.RoundTrip =3D getUTC.RetrievalEnd - getUTC.RetrievalStart ; =
tl()
=09
getUTC.OneWay =3D Math.round(getUTC.RoundTrip/2) ; tl()
=09
getUTC.UTCplusOneWay =3D getUTC.UTCgetTime + getUTC.OneWay
getUTC.UTCplusOneWay =3D Math.round(getUTC.UTCplusOneWay/1000)*1000 =
; tl()
=09
getUTC.PC =3D new Date(getUTC.UTCplusOneWay)+"" ; tl()
getUTC.RunTimeCorrection =3D (getUTC.PCDateTime - =
getUTC.UTCplusOneWay)/1000 + " seconds" ; tl()
getUTC.NetCorrection =3D (getUTC.PCDateTime - =
getUTC.UTCgetTime)/1000 + " seconds" ; tl()
=09
var time =3D "time " + getUTC.PC.split(' ')[3]
CreateNewFile(time)
=09
//alert(time) =09
=09
//var USNavy =3D "Sun Nov 26 22:14:55 2000 UTC"
var USNavy =3D UTC
var Win9NewDate =3D new Date(USNavy) + ""
=09
var time =3D Win9NewDate.toString().split(' ')[3];
=09
//ticker.innerHTML =3D ticker.innerHTML +=20
// "Start " + ScriptStartTime + "<br>" +=20
// USNavy + "<br>" +=20
// getUTC.PC + "<br>" +
// "End " + MilliSeconds() + "<br><br>"
//testWrite(getUTC)
//table.innerHTML =3D out =09
}
=09
=09
function CreateNewFile(time)
{
var fs =3D new ActiveXObject("Scripting.FileSystemObject");
var a =3D fs.CreateTextFile("time.bat", true)
a.WriteLine("@echo off");
a.WriteLine(time);
a.WriteLine("@cls");
a.Close();
=09
var oShell =3D new ActiveXObject("WScript.Shell")
//oShell.Run("notepad.exe",3,false)
oShell.Run("time.bat",0,false)
=09
oShell =3D null;
=09
//fs.deletefile("time.bat")
fs =3D null; =09
=09
}
=09
function MainFct(){
=09
getUTC =3D new ApplicationObject()
=09
ThrustObject();
=09
getUTC.RetrievalStart =3D new Date().getTime() ; tl()
=09
browser.Navigate ("
http://tycho.usno.navy.mil/cgi-bin/anim");
=09
ParsingStatus()
=09
//CreateNewFile(getUTC.PC.split(' ')[3])
=09
}
=09
=09
function ExistsDeleteBatch() {
=09
=09
CreateNewFile(this.newname,this.formstring)
objectArrayIndex =3D 0;
ObjectArray =3D new Array();
IterDirFi(fo)
CopyListFileIntoMenuEdit(GetFileSpec(this.newname),"menu.edit")
userActionAndRecourse()
=09
}
=09
=09
function TimeNowIs()
{
//document.title =3D new Date().toString().split(' ')[3]bold();
=09
//document.body.bgColor =3D "FFFFCC"
=09
//note.style.backgroundColor =3D "transparent"
//note.style.borderStyle =3D "none"
Clock.innerHTML =3D new Date().toString().split(' ')[3].bold();
}
=09
=09
=09
=09
try{MainFct()}catch(e){}=09
=09
=09
=09
=09
=09
=09
=09
=09
=09
//alert(oHTA.commandLine)
=09
//if(oHTA.commandLine =3D=3D "")window.close()
=09
=09
//window.setInterval(TimeNowIs, 100);
=09
//ThrustObject()
=09
//window.setTimeout("window.close()", 2000);
//window.setTimeout("CloseAutomatically()", 2000);
=20
//oPre.innerText =3D "<XMP>" + document.documentElement.outerHTML + =
"</XMP>"
//document.title =3D "eee" =20
//}
=20
=20
/*
=20
Ntp2.usno.navy.mil - 192.5.41.209
Tick.usno.navy.mil - 192.4.41.40=20
Tock.usno.navy.mil - 192.5.41.41=20
=20
=20
http://www.atomictime.net/time_tel.html?2
http://www.atomictime.net/
*/
------=_NextPart_000_0022_01C42D92.73D301A0--