|
发表于 2024-12-13 11:00:28
|
显示全部楼层
#include <WinHTTP.au3>
#include <Date.au3>
MsgBox(0, "", _Hdate())
Func _Hdate($WeekFlag = False)
Local $hOpen, $hConnect, $hRequest, $H_time, $str, $Date
Local $mon[13] = [12, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
Local $wee[8] = [7, "Mon,", "Tue,", "Wed,", "Thu,", "Fri,", "Sat,", "Sun,"]
Local $Week[8] = [7, "周一", "周二", "周三", "周四", "周五", "周六", "周日"]
Local $url = "www.beijing-time.org"
$hOpen = _WinHttpOpen()
$hConnect = _WinHttpConnect($hOpen, $url)
$hRequest = _WinHttpOpenRequest($hConnect, "head")
_WinHttpSendRequest($hRequest)
_WinHttpReceiveResponse($hRequest)
If _WinHttpQueryDataAvailable($hRequest) Then $str = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_DATE)
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
For $i = 1 To 12
$str = StringReplace($str, $mon[$i], $i)
Next
For $i = 1 To 7
$str = StringReplace($str, $wee[$i], $Week[$i])
Next
$str = StringSplit($str, " ")
$Date = $str[4] & "-" & $str[3] & "-" & $str[2] & " " & $str[5]
$Date = _DateAdd('h', 8, $Date)
If $WeekFlag Then $Date &= ' ' & $str[1]
Return $Date
EndFunc ;==>_Hdate |
|