tobject Posted July 1, 2010 Share Posted July 1, 2010 (edited) Anyone has simple DateTimeInZone($zone) function $zone is between -12 and +14which calculates everything, including daylight saving time? odd zones can be coded as 9.5 etcI just want 1 parameter without long complicated structures I tried _Date_Time_SystemTimeToTzSpecificLocalTimebut I get extra hour in some locationsJust spent two hours trying to write this thing and think I need help Or better if you have function GetDateTimeAtLocation($LATITUDE,$LONGITUDE)this could be a call to webservice like reliable site maybe Google or government etcThanks Edited July 1, 2010 by tobject Link to comment Share on other sites More sharing options...
Malkey Posted July 1, 2010 Share Posted July 1, 2010 Starting with a forum search on "LocalTime", produced this.#include <INet.au3> Local $sCity = InputBox("Local Time", "Enter City/Town", "Toowoomba") MsgBox(0, "Local Time", "City: " & $sCity & @CRLF & "Time: " & _GoogleTime($sCity)) ; Modified from http://www.autoitscript.com/forum/index.php?showtopic=56366&view=findpost&p=427666 Func _GoogleTime($sCity) $sSource = _INetGetSource("http://www.google.com/search?hl=en&q=time+" & $sCity) $aSRE = StringRegExp($sSource, "(?i)\>(\d+:\d+[ap]m)\<", 3) If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0) Return $aSRE[0] EndFunc ;==>_GoogleTime Link to comment Share on other sites More sharing options...
tobject Posted July 1, 2010 Author Share Posted July 1, 2010 (edited) ThanksHere's another service I found with coordinateshttp://worldtimeengine.com/dotime/59.9384619_30.2695335/now what the regexpression for that one?I can do a search for id="c0"><div class="result"> <div class="time Afternoon" id="c0"> 12:54 PM on Thursday, July 1, 2010 </div></div> Edited July 1, 2010 by tobject Link to comment Share on other sites More sharing options...
Malkey Posted July 1, 2010 Share Posted July 1, 2010 Try this. #include <INet.au3> Local $sCoords = InputBox("Local Time", "Enter Latitude_Longitude", "-27.55_151.95") MsgBox(0, "Local Time", "Lat._Long.: " & $sCoords & @CRLF & "Time: " & _worldtimeengine($sCoords)) ; Modified from http://www.autoitscript.com/forum/index.php?showtopic=56366&view=findpost&p=427666 Func _worldtimeengine($sCoords) $sSource = _INetGetSource("http://worldtimeengine.com/dotime/" & $sCoords & "/") Local $sPattern = '(?s)(?i)\<div class="result"\>\s*\<div class=.*?\>\s*(.+?)\</div' $aSRE = StringRegExp($sSource, $sPattern, 3) If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0) Return $aSRE[0] EndFunc ;==>_worldtimeengine Link to comment Share on other sites More sharing options...
tobject Posted July 1, 2010 Author Share Posted July 1, 2010 Thanks,my point is its like a free hack and they charge for regular time API service so they can pull the plug on free stuff any timebtw do you have a tool to generate regular expressions? and is expressions and XPath the same language ?I use SelectorGadget in Firefox to get XPath query Link to comment Share on other sites More sharing options...
tobject Posted July 2, 2010 Author Share Posted July 2, 2010 any other services? can http://www.pool.ntp.org/en/use.html be used for something like this? Link to comment Share on other sites More sharing options...
bartekd Posted June 20, 2011 Share Posted June 20, 2011 I know that this is an old post, but can someone help me out? I am trying to get this script to work, but I think google changed their page, and it is no longer working right. Here is the code that I see when I pull the source of the page. Can someone help with the stringregexp part? <td style="font-size: medium;"><b>22:27</b> Sunday (EDT) - <b>Time</b> in <b>Toronto, ON, Canada</b></td> I want to extract the time only. Starting with a forum search on "LocalTime", produced this. #include <INet.au3> Local $sCity = InputBox("Local Time", "Enter City/Town", "Toowoomba") MsgBox(0, "Local Time", "City: " & $sCity & @CRLF & "Time: " & _GoogleTime($sCity)) ; Modified from http://www.autoitscript.com/forum/index.php?showtopic=56366&view=findpost&p=427666 Func _GoogleTime($sCity) $sSource = _INetGetSource("http://www.google.com/search?hl=en&q=time+" & $sCity) $aSRE = StringRegExp($sSource, "(?i)\>(\d+:\d+[ap]m)\<", 3) If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0) Return $aSRE[0] EndFunc ;==>_GoogleTime Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now