Advertisement
duongvox99

Get Time

Feb 11th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.62 KB | None | 0 0
  1. ;~ Duong Vox
  2. #include <Array.au3>
  3.  
  4. Global $TimeZone = 7 ;Time zone in Vietnam: +7
  5.  
  6. $ohttp = ObjCreate("winhttp.winhttprequest.5.1")
  7. $ohttp.Open("GET", "http://www.google.com.vn/", False)
  8. $ohttp.Send()
  9. $Date = $ohttp.GetResponseHeader("Date")
  10. Global $iYear = StringMid($Date, 13, 4)
  11. Global $iMonth = StringMid($Date, 9, 3)
  12. Global $iDay = StringMid($Date, 6, 2)
  13. Global $iHour = StringMid($Date, 18, 2)
  14. Global $iMinute = StringMid($Date, 21, 2)
  15. Global $iSecond = StringMid($Date, 24, 2)
  16. $iMonth = _GetMonth($iMonth)
  17. Global $LastMonth = _DayOfMonth($iMonth - 1)
  18. Global $CurrentMonth = _DayOfMonth($iMonth)
  19. $iHour += $TimeZone
  20. Select
  21.     Case $iHour >= 24
  22.         $iDay += 1
  23.         $iHour -= 24
  24.     Case $iHour < 0
  25.         $iDay -= 1
  26.         $iHour += 24
  27. EndSelect
  28. Switch $iDay
  29.     Case $CurrentMonth + 1
  30.         $iMonth += 1
  31.         $iDayd = 1
  32.     Case 0
  33.         $iMonth -= 1
  34.         $iDay = $LastMonth
  35. EndSwitch
  36. Switch $iMonth
  37.     Case 0
  38.         $iMonth = 12
  39.         $iDay = 31
  40.         $iYear -= 1
  41.     Case 13
  42.         $iMonth = 1
  43.         $iDay = 1
  44.         $iYear += 1
  45. EndSwitch
  46.  
  47. Func _GetMonth($var)
  48.     Local $aMonth[13] = [12, "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]
  49.     Return _ArraySearch($aMonth, $var)
  50. EndFunc   ;==>_GetMonth
  51.  
  52. Func _DayOfMonth($sMonth)
  53.     Local $End
  54.     Switch $sMonth
  55.         Case 0, 1, 3, 5, 7, 8, 10, 12, 13
  56.             $End = 31
  57.         Case 4, 6, 9, 11
  58.             $End = 30
  59.         Case 2
  60.             If IsInt(@YEAR / 4) Then
  61.                 $End = 29
  62.             Else
  63.                 $End = 28
  64.             EndIf
  65.         Case Else
  66.             SetError(-1)
  67.             Return (0)
  68.     EndSwitch
  69.     Return ($End)
  70. EndFunc   ;==>_DayOfMonth
  71.  
  72. MsgBox(0, "Time", $iHour & ":" & $iMinute & ":" & $iSecond & @CRLF & $iDay & "/" & $iMonth & "/" & $iYear)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement