Welcome! Log In Create A New Profile

Advanced

[Solved] Re: To Read current date from Internet

Posted by sivakrith 
[Solved] Re: To Read current date from Internet
February 23, 2021 04:07PM
Hello,

Windev 22

Need to read the current date from the internet I use the following functions.
*****************************************
ls_url = "[www.somewebsite.com"];

IF InternetConnected() = True THEN
lb_httpResult = HTTPRequest(ls_URL)
Info(HTTPGetResult(httpHeader))
ELSE
Info("HTTP Error connecting web" + " Result : " + HTTPGetResult())
END
*********************************************

In HTTPGetResult(httpHeader) we have the required information. Should we parse that string to get the date or any functions (methods) available that will extract required values from the header for us. Any suggestions?

Happiness Always
BKR Sivaprakash



Edited 1 time(s). Last edit at 02/24/2021 08:46AM by sivakrith.
Re: To Read current date from Internet
February 24, 2021 08:45AM
Hello,

The below code worked for me

ldUTCDateTime, ldLocalDateTime is DateTime
cMyRequest is httpRequest
cMyResponse is httpResponse
cMyRequest..URL = ls_URL
cMyResponse = HTTPSend(cMyRequest)
lsDate is string = cMyResponse.Header["Date"]
ldUTCDateTime = Middle(lsDate,13,4) + SP_Get_MonthNumber(Middle(lsDate,9,3)) + Middle(lsDate,6,2) + Middle(lsDate,18,2) + Middle(lsDate, 21,2) + Middle(lsDate,24,2)
ldLocalDateTime = DateTimeUTCToLocal(ldUTCDateTime)
info(ldLocalDateTime)


PROCEDURE SP_Get_MonthNumber(LOCAL p_sMonth is string)

SWITCH Lower(p_sMonth)
CASE "jan"
RESULT "01"
CASE "feb"
RESULT "02"
CASE "mar"
RESULT "03"
CASE "apr"
RESULT "04"
CASE "may"
RESULT "05"
CASE "jun"
RESULT "06"
CASE "jul"
RESULT "07"
CASE "aug"
RESULT "08"
CASE "sep"
RESULT "09"
CASE "oct"
RESULT "10"
CASE "nov"
RESULT "11"
CASE "dec"
RESULT "12"
END
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: