Retrieving Date and Time From The Internet

stephen barncard stephenREVOLUTION2 at barncard.com
Wed Aug 17 01:35:55 EDT 2011


 I thought it could be done directly with a time server, and one can!
I did some dicking around with sockets and made this up.

this uses the Daytime Protocol
(RFC-867)<http://www.nist.gov/pml/div688/grp40/its.cfm>

function returnNISTime

      -- returns UTC time in RFC-867 (Daytime) format

      -- sqb @ the house of cubes

      put "time-C.timefreq.bldrdoc.gov:13" into pServerURL

      set the socketTimeoutInterval to 1000

      open socket to pServerURL

      write "" to socket pServerURL

      read from socket pServerURL for 49

      put it into a

      put the result into b

      close socket pServerURL

      delete line 1 of a

      return  a

end returnNISTime


--------------------------------------

put returnNISTime()


returns:


55790 11-08-17 04:57:45 50 0 0 102.3 UTC(NIST) *


note that everything one needs is here, including the year.

This clock data is read directly from a source that is mission critical and
cannot go down.


THe only caveat: if you are on a LAN then you must open up port 13 on the
router


---------

The NIST format <http://www.boulder.nist.gov/timefreq/service/its.htm> : is
* JJJJJ YR-MO-DA HH:MM:SS TT L H msADV UTC(NIST) OTM*

 JJJJJ - the Julian Date is : 53746
  YR-MO-DA - the Date is : 2006-01-11
  HH:MM:SS - the Time in UTC is : 21:28:49
  TT - Indication whether USA is on Standard Time (ST) or Daylight Saving
Time (DST) : 00 (Standard Time)
  L - Leap second at the end of the month (0: no, 1: +1, 2: -1) : 0
  H - Health of the server (0: healthy, >0: errors) : 0
  msADV - time code advanced in milliseconds to compensate network delays :
266.1
  UTC(NIST) - the originator of this time code : UTC(NIST)
  OTM - on-time marker : *


hope you all can use this.


On 16 August 2011 15:11, Bob Sneidar <bobs at twft.com> wrote:

> Thanks Waren and Scott. I will have a look at those. I can extrapolate UTX
> time from those zones I suppose, and then do the math for the particular
> time zone in the system settings.
>
> Thanks.
> Bob
>
>
> Stephen Barncard
San Francisco Ca. USA

more about sqb  <http://www.google.com/profiles/sbarncar>



More information about the Use-livecode mailing list