Retrieving Date and Time From The Internet
bobs at twft.com
Tue Aug 16 13:13:58 CDT 2011
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 "<BR>*UTC*"
replace "<BR>" 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
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
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
> 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 | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode