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++.




Function GetUTC() As String
    Url = "http://tycho.usno.navy.mil/cgi-bin/timer.pl"
    With CreateObject("MSXML2.XMLHTTP.6.0")
        .Open "GET", Url, False
        .send
        arrt = Split(.responseText, vbLf)
    End With
    For Each t In arrt
        If InStr(t, "UTC") Then
            GetUTC = StripHttpTags(t)
 
            Exit For
        End If
    Next
End Function
 
Function StripHttpTags(s)
    With New RegExp
        .Global = True
        .Pattern = "\<.+?\>"
        If .Test(s) Then
            StripHttpTags = .Replace(s, "")
        Else
            StripHttpTags = s
        End If
    End With
End Function
 
WScript.StdOut.Write GetUTC
WScript.StdOut.WriteLine