I may have sent you a version that was bugged. This is the final one I came up 
with:

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 "<BR>*UTC*"
   replace "<BR>" with empty in theResult
   put word 1 to 3 of theResult into theResult
   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
   
   if theFormat is "seconds" then
      put word -1 of theResult into theResult
      convert theResult to seconds
   end if
   
   return theResult
end realTime

Bob

On Aug 15, 2011, at 3:06 PM, Peter M. Brigham, MD wrote:

> In my testing, the convert command fails with the date as given by the 
> webpage, because the date lacks the year. Hence the need to insert the year 
> first. And there needs to be no comma in the date.
> 
> -- Peter
> 
> Peter M. Brigham
> pmb...@gmail.com
> http://home.comcast.net/~pmbrig
> 
> 
> On Aug 15, 2011, at 3:54 PM, Bob Sneidar wrote:
> 
>> Maybe a little more concise:
>> 
>> function realTime theFormat
>>   breakpoint
>>   put "http://tycho.usno.navy.mil/cgi-bin/timer.pl"; into theURL
>>   get url theURL
>>   put it into theResult
>>   filter theResult with "<BR>*UTC*"
>>   replace "<BR>" with empty in theResult
>>   put word 1 to 3 of theResult into theResult
>>   if theFormat is "seconds" then
>>       put word -1 of theResult into theResult
>>       convert theResult to seconds
>>   end if
>>   -- add more conversions here
>>   return theResult
>> end realTime
>> 
>> On Aug 15, 2011, at 12:15 PM, Peter M. Brigham, MD wrote:
>> 
>>> I'll try sending this again, revised (third time -- someone let me know 
>>> please if it's getting through). It returns the time fast enough (with a 
>>> speedy connection) to be within a second or so.
>>> 
>>> ------------------
>>> 
>>> You can fetch the time from the U.S. Naval Observatory atomic clock. This 
>>> assumes an internet connection, though. If what you want to do is timestamp 
>>> something, just fetch the "universal time" line (line 6 of the HTML 
>>> returned):
>>> 
>>> function fetchTime
>>> put line 6 of URL "http://tycho.usno.navy.mil/cgi-bin/timer.pl"; into t
>>> -- returns "<BR>Aug. 15, 19:12:46 UTC" & tab & tab & "Universal Time"
>>> replace "<BR>" with empty in t
>>> set the itemdelimiter to tab
>>> delete item 2 to -1 of t
>>> set the itemdelimiter to comma
>>> delete word -1 of t
>>> put t into ts
>>> put the short date into di
>>> convert di to dateitems
>>> put item 1 of di into tYr
>>> put space & tYr after item 1 of t
>>> put space & tYr after item 1 of ts
>>> replace comma with empty in t
>>> replace comma with empty in ts
>>> convert ts to seconds
>>> put t & cr & ts
>>> return t -- if you want "Aug. 15, 19:12:46"    or,
>>> return ts -- if you want the seconds
>>> end fetchTime
>>> 
>>> -- Peter
>>> 
>>> Peter M. Brigham
>>> pmb...@gmail.com
>>> http://home.comcast.net/~pmbrig
>>> On Aug 15, 2011, at 1:25 PM, Bob Sneidar wrote:
>>> 
>>>> This returns a ton of html, from which the date time can be filtered using 
>>>> "<H2>*", but since it takes about 30 seconds to run, and returns 32 
>>>> entries, I am not sure how useful this would for him, if he wanted an 
>>>> exact time (within a second or two). 
>>>> 
>>>> Time servers are NTP:\\ aren't they? Looks like the revURL library does 
>>>> not support NTP, or not that I can see. Any attempt to use it in a URL 
>>>> returns empty in it and invalid URL: in the result. 
>>>> 
>>>> A quick browse for http based time servers came up dry. 
>>>> 
>>>> Bob
>>>> 
>>>> 
>>>> On Aug 13, 2011, at 11:15 AM, Mark Wieder wrote:
>>>> 
>>>>> Gregory-
>>>>> 
>>>>> Saturday, August 13, 2011, 10:33:29 AM, you wrote:
>>>>> 
>>>>>> Taking another kick at the cat here.  I’d like to use something like
>>>>> 
>>>>>>    get url (http://[time server address])
>>>>> 
>>>>> How's this?
>>>>> 
>>>>> http://tycho.usno.navy.mil/cgi-bin/anim
>>>>> 
>>>>> -- 
>>>>> -Mark Wieder
>>>>> mwie...@ahsoftware.net
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> 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
>>> 
>>> 
>>> _______________________________________________
>>> 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
> 
> 
> _______________________________________________
> 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

Reply via email to