I have code, only in C# as I do not have VB installed. I hope this helps. Interesting question, I have learned something today :)
Console application is as follows:
static void Main(string[] args)
{
string latitude = "32.4917";
string longitude = "53.6167";
string uri = string.Format(
"http://www.earthtools.org/timezone/{0}/{1}", latitude, longitude);
string xml = PostRequest(uri, string.Empty, MediaTypeNames.Text.Html);
timezone instance = Deserialize(xml);
DateTime localTime = instance.GetLocalTime();
Console.WriteLine(
"The date and time is : " + localTime.ToString("dd MMM yyyy HH:mm:ss"));
Console.Read();
}
private static timezone Deserialize(string xmlText)
{
using (MemoryStream memStream =
new MemoryStream(Encoding.UTF8.GetBytes(xmlText)))
{
XmlSerializer ser = new XmlSerializer(typeof(timezone));
return (timezone)ser.Deserialize(memStream);
}
}
private static string PostRequest(string uri, string msgBody, string contentType)
{
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(uri);
webReq.Timeout = 60 * 1000;
webReq.Method = "POST";
webReq.ContentType = contentType;
webReq.ContentLength = msgBody.Length;
using (StreamWriter streamOut =
new StreamWriter(webReq.GetRequestStream(), System.Text.Encoding.ASCII))
{
streamOut.Write(msgBody);
streamOut.Flush();
streamOut.Close();
}
string response = null;
using (StreamReader streamIn =
new StreamReader(webReq.GetResponse().GetResponseStream()))
{
response = streamIn.ReadToEnd();
streamIn.Close();
}
return response;
}
The definition for the class timezone is as follows:
[Serializable()]
public class GpsCoordinates
{
public string latitude { get; set; }
public string longitude { get; set; }
}
[Serializable()]
public class timezone
{
public string version { get; set; }
public GpsCoordinates location { get; set; }
public string offset { get; set; }
public string suffix { get; set; }
public string localtime { get; set; }
public string isotime { get; set; }
public string utctime { get; set; }
public string dst { get; set; }
public DateTime GetLocalTime()
{
return DateTime.Parse(localtime);
}
}
Output is as follows:
The date and time is : 04 May 2012 02:46:01