Re: Retrieving Date and Time From The Internet

2011-08-16 Thread Bob Sneidar
Okay, I contacted the USNO site via email and requested that they include the 
year in the returned date/time. 

I have a modified script which includes the year, but I caution you that the 
convert command is getting the current year from the system if it is not 
supplied, which defeats the whole purpose of getting the Real Time. We are 
still at the mercy of the system date and whatever the user sets it to. 

Until someone can come up with an HTTP link that returns the year with the date 
and time, or else Livecode supports NTP queries, we are SOL. I have searched 
high and low and cannot find one single web site besides 
http://tycho.usno.navy.mil/cgi-bin/timer.pl that returns anything usable. Leave 
it up to a sailor to get you most of the way there, and then let you swim the 
rest of the way! LOL! (I'm an ex-sailor so I can say that). 

function realTime theFormat, useOffset
   if useOffset is empty then put false into useOffset
   put "http://tycho.usno.navy.mil/cgi-bin/timer.pl"; into theURL
   get url theURL
   put it into theResult
   filter theResult with "*UTC*"
   replace "" with empty in theResult
   put word 1 to 3 of theResult into theResult
   put word 4 of the internet date into theYear -- bummer relies on system 
datetime
   
   if useOffset then
  put word -1 of theResult into theTime
  put word -1 of the internet date into theZoneOffset
  put theZoneOffset /100 into theZoneOffset
  set the itemdelimiter to ":"
  put (item 1 of theTime + theZoneOffset) into item 1 of theTime
  put theTime into word -1 of theResult
   end if
   
   put space & theYear after word 2 of theResult
   
   if theFormat is "seconds" then
  -- not entirely accurate as it returns the same value with the year
  -- as it does without it, leading me to believe the convert command 
  -- is accessing the system datetime to get the year if it is not provided
  convert theResult to seconds
   end if
   
   return theResult
end realTime

Bob


On Aug 16, 2011, at 10:37 AM, J. Landman Gay wrote:

> On 8/16/11 12:31 PM, Gregory Lypny wrote:
>> Hi Stephen,
>> 
>> Yes, and Bob Sneidar has kindly provided us with a function that does
>> that (see "Re: Grabbing the Date and Time From a Time Server on the
>> Internet”).  The only thing it lacks at the moment is the year.  I
>> asked about doing the same with a remote computer only to explore an
>> alternative.
> 
> I'm not sure if your setup will allow it, but the actual delivery date and 
> time will be listed on the server. Can you just retrieve the date from there, 
> separately from the client app? Does the date need to be embedded in the file 
> itself?
> 
> -- 
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software   | http://www.hyperactivesw.com
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Retrieving Date and Time From The Internet

2011-08-16 Thread Scott Rossi
Recently, Bob Sneidar wrote:

> Until someone can come up with an HTTP link that returns the year with the
> date and time, or else Livecode supports NTP queries, we are SOL. I have
> searched high and low and cannot find one single web site besides
> http://tycho.usno.navy.mil/cgi-bin/timer.pl that returns anything usable.
> Leave it up to a sailor to get you most of the way there, and then let you
> swim the rest of the way! LOL! (I'm an ex-sailor so I can say that).

A fun challenge.  Here's one option, limited to a single time (US Eastern),
with no guarantee of reliability (can any Web-based service truly claim
this?):

function timeStamp
   put url "http://www.atomictime.net/front.html"; into temp
   wait 500 millisecs with messages
   put url "http://www.atomictime.net/time_tel.html?2"; into temp
   repeat with N = number of lines of temp down to 1
  if line N of temp is not empty then return line N of temp
   end repeat
end timeStamp

The reason for the dual URLs is the host requires initial access through a
home page.  Only thing I can guess is there's some back-end foolery going on
that's not accessible (at least I can't see anything that's apparent, but
maybe that's just me).

I tried setting my system clock back 2 hours and the page continues to
return the current Eastern time, so the service *appears* to be legit.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX Design



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Retrieving Date and Time From The Internet

2011-08-16 Thread Warren Samples
On Tuesday, August 16, 2011 11:13:58 AM Bob Sneidar wrote:
> Okay, I contacted the USNO site via email and requested that they include the 
> year in the returned date/time. 

You could try this:

http://www.worldtimeserver.com/current_time_in_CA-QC.aspx

Your time info is here in the html it returns (example):



5:10 PM



Tuesday, August 16, 2011


Eastern Daylight Time (EDT) -0400 
UTC

Isolate this from the rest of the source and filter out the lines that begin 
with <, and you'll have what you're looking for. If you want a different city, 
just select one 
from the list and copy that URL.

Warren

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Retrieving Date and Time From The Internet

2011-08-16 Thread Bob Sneidar
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


On Aug 16, 2011, at 2:10 PM, Warren Samples wrote:

> On Tuesday, August 16, 2011 11:13:58 AM Bob Sneidar wrote:
>> Okay, I contacted the USNO site via email and requested that they include 
>> the year in the returned date/time. 
> 
> You could try this:
> 
> http://www.worldtimeserver.com/current_time_in_CA-QC.aspx
> 
> Your time info is here in the html it returns (example):
> 
>
>
>5:10 PM
>
>
>
>Tuesday, August 16, 2011
>
>
>Eastern Daylight Time (EDT) -0400 
> UTC
> 
> Isolate this from the rest of the source and filter out the lines that begin 
> with <, and you'll have what you're looking for. If you want a different 
> city, just select one 
> from the list and copy that URL.
> 
> Warren
> 
> ___
> 

> A fun challenge.  Here's one option, limited to a single time (US Eastern),
> with no guarantee of reliability (can any Web-based service truly claim
> this?):
> 
> function timeStamp
>   put url "http://www.atomictime.net/front.html"; into temp
>   wait 500 millisecs with messages
>   put url "http://www.atomictime.net/time_tel.html?2"; into temp
>   repeat with N = number of lines of temp down to 1
>  if line N of temp is not empty then return line N of temp
>   end repeat
> end timeStamp
> 
> The reason for the dual URLs is the host requires initial access through a
> home page.  Only thing I can guess is there's some back-end foolery going on
> that's not accessible (at least I can't see anything that's apparent, but
> maybe that's just me).
> 
> I tried setting my system clock back 2 hours and the page continues to
> return the current Eastern time, so the service *appears* to be legit.
> 
> Regards,
> 
> Scott Rossi
> Creative Director
> Tactile Media, UX Design

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Retrieving Date and Time From The Internet

2011-08-16 Thread stephen barncard
 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)

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  : is
* J YR-MO-DA HH:MM:SS TT L H msADV UTC(NIST) OTM*

 J - 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  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  
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Retrieving Date and Time From The Internet

2011-08-17 Thread Andre Garzia
Folks,

this thread made me curious...

I present to you a simple SNTP stack

go stack "http://andregarzia.com/stacks/libNTPToy.livecode";

It is a quick and dirty implementation with no error checking. It has one
function getTime(), you pass the NTP server and it returns the current date
and time in seconds format. I tried with our official Brazilian time servers
and it worked.

Hope this helps. By the way, I don't truly understand the NTP protocol, I
picked a couple ruby and python code and converted to livecode with the aid
of wireshark marvelous sniffer tool to see the damn datagrams flowing. (I
hate binary protocols)

=)

Cheers
andre
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Retrieving Date and Time From The Internet

2011-08-17 Thread Gregory Lypny
Much obliged, Scott.

Gregory


On Tue, Aug 16, 2011, at 6:46 PM, Scott Rossi wrote:

> A fun challenge.  Here's one option, limited to a single time (US Eastern),
> with no guarantee of reliability (can any Web-based service truly claim
> this?):
> 
> function timeStamp
>   put url "http://www.atomictime.net/front.html"; into temp
>   wait 500 millisecs with messages
>   put url "http://www.atomictime.net/time_tel.html?2"; into temp
>   repeat with N = number of lines of temp down to 1
>  if line N of temp is not empty then return line N of temp
>   end repeat
> end timeStamp
> 
> The reason for the dual URLs is the host requires initial access through a
> home page.  Only thing I can guess is there's some back-end foolery going on
> that's not accessible (at least I can't see anything that's apparent, but
> maybe that's just me).

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Retrieving Date and Time From The Internet

2011-08-17 Thread Bob Sneidar
You guys never cease to amaze me. Well done! Now if a single developer can 
produce results like this overnight, I wonder why the very capable devs at 
RunRev cannot create a world time that does the same thing? 

Bob


> Folks,
> 
> this thread made me curious...
> 
> I present to you a simple SNTP stack
> 
> go stack "http://andregarzia.com/stacks/libNTPToy.livecode";
> 
> It is a quick and dirty implementation with no error checking. It has one
> function getTime(), you pass the NTP server and it returns the current date
> and time in seconds format. I tried with our official Brazilian time servers
> and it worked.
> 
> Hope this helps. By the way, I don't truly understand the NTP protocol, I
> picked a couple ruby and python code and converted to livecode with the aid
> of wireshark marvelous sniffer tool to see the damn datagrams flowing. (I
> hate binary protocols)
> 
> =)
> 
> Cheers
> andre

On Aug 16, 2011, at 10:35 PM, stephen barncard wrote:

> 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)
> 
> function returnNISTime


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Retrieving Date and Time From The Internet

2011-08-17 Thread Gregory Lypny
Hi Stephen Barncard and Andre Garzia,

Cool functions!  Thank you for sharing.  Never thought my original question was 
going to kick up so much dust!

Gregory


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Retrieving Date and Time From The Internet

2011-08-17 Thread Andre Garzia
Gregory,

please give me feedback if you are able to query your ntp server with my
stack!

cheers
andre

On Wed, Aug 17, 2011 at 1:38 PM, Gregory Lypny
wrote:

> Hi Stephen Barncard and Andre Garzia,
>
> Cool functions!  Thank you for sharing.  Never thought my original question
> was going to kick up so much dust!
>
> Gregory
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
http://www.andregarzia.com All We Do Is Code.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode