06-12-2017, 02:51 AM
I want to convert the following sources to QM.
But, "QM? ----" I don't know the command for the three lines below the comment.
Could you tell me how to change it?
Function Function10
But, "QM? ----" I don't know the command for the three lines below the comment.
Could you tell me how to change it?
Function Function10
str Headers =
;Host: nist.time.gov
;Connection: keep-alive
;Cache-Control: max-age=0
;Upgrade-Insecure-Requests: 1
;User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
;Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
;Accept-Encoding: deflate, sdch
str ResponeHeader HTML
Http HttpWebRequest.Connect("http://nist.time.gov" 0 0 0)
,,HttpWebRequest.Get2("/actualtime.cgi?lzbc=siqm9b" HTML 0 INTERNET_FLAG_NO_COOKIES|INTERNET_FLAG_NO_CACHE_WRITE ResponeHeader Headers)
if(!findrx(HTML "(?<=\btime='')[^'''']*" 0 RX_DOTALL _s)>=0)
,out _s
;QM ?----
;double milliseconds = Convert.ToInt64(time) / 1000.0;
;DateTime d.FromStr(1970, 1, 1)AddMilliseconds(milliseconds).ToLocalTime();
;ret dateTime.ToString()
;----------------
;out
;str endTime=sub.NistTime
;out endTime
#sub NistTime
;Credit goes to Nemo from Stack Overflow:
;http://stackoverflow.com/questions/6435099/how-to-get-datetime-from-the-internet/6435207#6435207
function~
CsScript x.AddCode("")
ret x.Call("Test.iNetTime")
#ret
using System;
using System.IO;
using System.Net;
using System.Net.Cache;
using System.Text.RegularExpressions;
public class Test
{
,public static string iNetTime()
,{
,,DateTime dateTime = DateTime.MinValue;
,,HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://nist.time.gov/actualtime.cgi?lzbc=siqm9b");
,,request.Method = "GET";
,,request.Accept = "";
,,request.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)";
,,request.ContentType = "application/x-www-form-urlencoded";
,,request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); //No caching
,,HttpWebResponse response = (HttpWebResponse)request.GetResponse();
,,if (response.StatusCode == HttpStatusCode.OK)
,,{
,,,StreamReader stream = new StreamReader(response.GetResponseStream());
,,,string html = stream.ReadToEnd();
,,,string time = Regex.Match(html, @"(?<=\btime="")[^""]*").Value;
,,,double milliseconds = Convert.ToInt64(time) / 1000.0;
,,,dateTime = new DateTime(1970, 1, 1).AddMilliseconds(milliseconds).ToLocalTime();
,,}
,,return dateTime.ToString();
,}
}