The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM DATE conversion
#1
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
Code:
Copy      Help
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();
,}    
}


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)