Re: Getting the Date and Time From a Time Server
- To: mathgroup at smc.vnet.net
- Subject: [mg120903] Re: Getting the Date and Time From a Time Server
- From: Gregory Lypny <gregory.lypny at videotron.ca>
- Date: Sun, 14 Aug 2011 20:19:46 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201108131047.GAA25453@smc.vnet.net>
Thank you, Hans. Port 13 is blocked. Safari tells me that I'm not allowed to use a restricted network port. I will look at your other alternatives. Gregory On Sun, Aug 14, 2011, at 3:01 PM, Hans Michel wrote: > First of all need more information than what you get. > > In[3]:= XML`Parser`XMLGetString["<?xml version='1.0' \ > encoding='UTF-8'?><!DOCTYPE NISTTime [<!ENTITY datetime SYSTEM > 'http://time.nist.gov:13/'><!ELEMENT NISTTime \ > (#PCDATA)>]><NISTTime>&datetime;</NISTTime>"] > > Out[3]= XMLObject[ > "Document"][{XMLObject["Declaration"]["Version" -> "1.0", > "Encoding" -> "UTF-8"], > XMLObject["Doctype"]["NISTTime", > "InternalSubset" -> > "<!ENTITY datetime SYSTEM 'http://time.nist.gov:13/'><!ELEMENT \ > NISTTime (#PCDATA)*>"]}, > XMLElement[ > "NISTTime", {}, {"55787 11-08-14 18:45:50 50 0 0 823.4 UTC(NIST) \ > *"}], {}, "Valid" -> True] > > = http://reference.wolfram.com/mathematica/XML/tutorial/ImportingXML.html > > This works for me also. Have you tried just using the URL in your browser on your network. Port 13 may be blocked. > If not blocked then try the following. > > XML`Parser`XMLGetString["<?xml version='1.0' \ > encoding='UTF-8'?><!DOCTYPE NISTTime [<!ENTITY datetime SYSTEM > 'http://time.nist.gov:13/'><!ELEMENT NISTTime \ > (#PCDATA)>]><NISTTime>&datetime;</NISTTime>", > "AllowRemoteDTDAccess" -> True, "AllowUnrecognizedEntities" -> True, > "ValidateAgainstDTD" -> True] > > In original reply I also stated that it may not work in your system due to firewall issue or Mathematica front end setting and XML parser settings > > ("AllowUnrecognizedEntities" in XML attributes in Mathematica is defaulted to True. If entities can not be fetched on your system you may need to adjust this attribute in Mathematica. There may also be firewall issues.) > > You may want to try the route of GetURL and excape out to Java. > http://library.wolfram.com/examples/GetURL/ > > Hans > > From: Gregory Lypny [mailto:gregory.lypny at videotron.ca] > Sent: Sunday, August 14, 2011 1:01 PM > To: Hans Michel > Cc: mathgroup at smc.vnet.net > Subject: Re: Getting the Date and Time From a Time Server > > Hi Hans, > > Thank you for the script. Unfortunately, I get the following Mathematica error message when I run it. > > > XML`Parser`XMLGetString::prserr: NetAccessorException: Could not open file: http://time.nist.gov:13/ at Line: 2 Character: 88. > > > Regards, > > Gregory > > > On Sat, Aug 13, 2011, at 2:49 PM, Hans Michel wrote: > > > Using Mathematica Version 7 > > $Version > > "7.0 for Microsoft Windows (32-bit) (February 18, 2009)" > > Import["http://time.nist.gov:13/"] > With port numbers fails. > > Try the following trick: > > In[1]:= getNISTTime[] := > Module[{NISTTimeXML, result}, > NISTTimeXML = > ImportString[ > "<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE NISTTime \ > [<!ENTITY datetime SYSTEM > 'http://time.nist.gov:13/'><!ELEMENT NISTTime \ > (#PCDATA)>]><NISTTime>&datetime;</NISTTime>", "XML"]; > result = > First[Cases[NISTTimeXML, XMLElement["NISTTime", {}, ___], > Infinity]][[3]][[1]]; > result]; > > > In[2]:= getNISTTime[] > > Out[2]= "55786 11-08-13 18:24:53 50 0 0 441.7 UTC(NIST) *" >
- References:
- Getting the Date and Time From a Time Server
- From: Gregory Lypny <gregory.lypny@videotron.ca>
- Getting the Date and Time From a Time Server