Hi Andre,
Neat tip from Frank and a good script to implement it, but your script always returns GMT. This may have been what you were after, but here is a version that gives local time and also checks that the headers contain a date.


function getServerTime serverURL
  -- get the URL & read the headers
  put "http://"; & serverURL into varURL
  get URL varURL
  put libURLLastRHHeaders() into varDate

  -- check if the headers contain a date
  put lineOffset("Date:",varDate) into tLineNum
  if tLineNum = 0 then return empty

  -- get just the date information in GMT
  put word 2 to 6 of line tLineNum of varDate & " +0000" into tDate
  convert tDate from internet date and time to dateItems

  -- now get your local internet date & read the time zone
  put last word of the internet date into tZone
  -- separate it into hours & minutes and add to the GMT date time
  put char 1 of tZone & char -2 to -1 of tZone into tZoneMins
  delete char -2 to -1 of tZone
  add tZone to item 4 of tDate
  add tZoneMins to item 5 of tDate

  -- convert back to the required format & return it
  convert tDate to system date and time
  return tDate
end getServerTime

Cheers,
Sarah
[EMAIL PROTECTED]
http://www.troz.net/Rev/

On 6 Apr 2004, at 10:28 pm, Andre Rombauts wrote:

Great tip Frank, indeed! Thanks. It is working fine... Here is the script I
made. The mouseUp is a button handler being invoked after typing a server
URL under the form www.name.domain. The server headers contain the Internet
time but without the UTC + offset, thus the function adds +0000 to set it
correctly the GMT time returned.


Once more an example of how easy it is to 'create' with Run Rev!

=====

on mouseUp
  put empty into field "fDate"
  put getServerTime (the text of field "inputURL") into varDate
  convert varDate from internet date and time to system date and time
  put varDate into field "fDate"
end mouseUp

function getServerTime serverURL
  put "http://"; & serverURL into varURL
  get URL varURL
  put libURLLastRHHeaders() into varDate
  set itemDelimiter to space
  return item 2 to 6 of line lineOffset("Date:",varDate) of varDate & "
+0000"
end getServerTime

=====

Most servers return the current server time in the Date: HTTP
header, so you should be able to ask for any page on the
server to get the time.  The date is formatted in a standard
"Internet" time (see the RR docs).

The response headers will look like this:

HTTP/1.1 200 OK\r\n
Server: foo\r\n
Date: Mon, 05 Apr 2004 16:59:24 GMT\r\n
...\r\n
\r\n


-- Frank


_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution




_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to