Task

Create a program that downloads the time from this URL:   http://tycho.usno.navy.mil/cgi-bin/timer.pl   and then prints the current UTC time by extracting just the UTC time from the web page's HTML. Alternatively, if the above url is not working, grab the first date/time off this page's talk page.



If possible, only use libraries that come at no extra monetary cost with the programming language and that are widely available and popular such as CPAN for Perl or Boost for C++.




include unix/socket.fs
 
: extract-time ( addr len type len -- time len )
  dup >r
  search 0= abort" that time not present!"
  dup >r
  begin -1 /string  over 1- c@ [char] > = until       \ seek back to <BR> at start of line
  r> - r> + ;
 
s" tycho.usno.navy.mil" 80 open-socket
dup s\" GET /cgi-bin/timer.pl HTTP/1.0\n\n" rot write-socket
dup pad 4096 read-socket
s\" \r\n\r\n" search 0= abort" can't find headers!"   \ skip headers
s" UTC" extract-time type cr
close-socket