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

Reply via email to