Jump to content

Google World Time


gseller
 Share

Recommended Posts

Hey all, Thanks to Nahuel for helping me and Smoke_N's function and INETGetSource and StringRegExp we can now tap into www.google.com Latest API for time and timezone information. They way it works is if you go to www.google.com and type for your search "time morocco" you will get the time and date and timezone information at the top of the search. I was having fits getting this to work and Nahuel helped me get-R-done in the help section...

Herer is the file:

Please give me some feedback, I still have a slight bug in that it still shows the < b > tags in the string. I tried working them out but coulcn't get the right StringRegExp. If someone can work that out and post it would be awesome..

google_worldtime.au3

Updated:: Added martin's suggestion Post #2

Updated:: Corrected the erroring out if not found and closing.

Updated:: Added martins new improved function

Updated:: made cosmetic changes

Updated:: Added Copy to clipboard

Updated:: Preset Buttons

Any new ideas are awesomely appreciated.

Edited by gesller
Link to comment
Share on other sites

Hey all, Thanks to Nahuel for helping me and Smoke_N's function and INETGetSource and StringRegExp we can now tap into www.google.com Latest API for time and timezone information. They way it works is if you go to www.google.com and type for your search "time morocco" you will get the time and date and timezone information at the top of the search. I was having fits getting this to work and Nahuel helped me get-R-done in the help section...

Herer is the file:

Please give me some feedback, I still have a slight bug in that it still shows the < b > tags in the string. I tried working them out but coulcn't get the right StringRegExp. If someone can work that out and post it would be awesome..

To get rid of the bold tags you could just do this

$aSRE[0] = StringReplace($aSRE[0],'<b>','')
    Return StringReplace($aSRE[0],'</b>','')

Needs some work though because I get '0.' for London and Paris. New York and Morocco work ok though. (Stopped trying after that.)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

London and Paris, when searched on Google, have other bolded values below them for cities in the US called Paris and London. I guess that breaks the regular expression.

(Try searching "time london" and "time paris" to see what I'm talking about; compare those to "time new york" and "time morocco".)

It's a pretty cool script, though; good job gesller!

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

Thank You, thank you! I will be using this one at work alot. I know about the added info for like you said london or russia or someplace that has multiple time zones but don't know how I could go about setting it up to grab the entire expression from google. Any ideas would be very welcome..

Link to comment
Share on other sites

Thank You, thank you! I will be using this one at work alot. I know about the added info for like you said london or russia or someplace that has multiple time zones but don't know how I could go about setting it up to grab the entire expression from google. Any ideas would be very welcome..

This is a rather crude way to get the times for the first city found when there is more than one, or more than one time zone.

StringRegExp is the best way but I can't see how to do it either.

Func _GoogleTime($sCity)
    Dim $sSource[10],$n
    $ss='alt="Clock"></td><td valign=top><b>'
    $n = 0
    
    $sSource = _INetGetSource("http://www.google.com/search?hl=en&q=time+" & $sCity)
    $aSRE=StringRegExp($sSource,'<(?i)td valign=middle><(?i)b>(.*?)<(?i)/td>',3)
    If $aSRE = 1 Then
    ;FileWrite($sCity & ".tme",$sSource)
        $a = StringInStr($sSource,'alt="Clock"></td><td valign=top><b>')
        $sSource = StringMid($sSource,StringInStr($sSource,$ss) + StringLen($ss),100)
        $sSource = StringReplace($sSource,'<br><table border=0','|')
        
        $aSRE = StringSplit($sSource,'|')
        If $aSRE[0] = 1 Then
            MsgBox(4096,"Location", "NOT FOUND")
        Else
            $aSRE[1] = StringReplace($aSRE[1],'<b>','')
            Return StringReplace($aSRE[1],'</b>','')
            Return $aSRE[1]
        EndIf
    Else
        $aSRE[0] = StringReplace($aSRE[0],'<b>','')
        Return StringReplace($aSRE[0],'</b>','')
    EndIf
    
EndFunc;==>_GoogleTime()
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@ sandman - The london Paris issue is corrected with martin's new function

@ martin - Sweet Fix!! Thank You!

@ ReFran - I remember seeing that back in the late 90's was way to loud then and is even more so now.. LOL Please give the new file in first post a try to see if this works for you?

Thanks all for your help and support, hope someone gets some use out of this. I know everyone in my office will LOL

Please keep the ideas coming. I want to add or create a Google spellcheck into this if anyone has ideas?

Link to comment
Share on other sites

Please keep the ideas coming. I want to add or create a Google spellcheck into this if anyone has ideas?

Skizmata did a good sspellchecker and so did Toady. AzKay did a very neat online _Define.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Yes, I love the one Skizmata did and have been tinkering with it to see if I could change it to do editing within a listview or edit (for my purposes)but no luck so far. I will have to search for Toady's, have not seen it yet. Thank you...

Link to comment
Share on other sites

Hi,

looks good now .... also if I would prefer to see 22:30 (international time format) instead of 10:30 pm.

Where is the button to update the system time?

Where is the button for "Sterkrade" (the part of the town where I live).

Best regards, Reinhard

Link to comment
Share on other sites

Hi,

looks good now .... also if I would prefer to see 22:30 (international time format) instead of 10:30 pm.

Where is the button to update the system time?

Where is the button for "Sterkrade" (the part of the town where I live).

Best regards, Reinhard

@ReFran

This will update your system time. http://www.autoitscript.com/forum/index.php?showtopic=55907

"Sterkrade" is not defined by google to have a time setup. Sorry... <_<

Also, I do not see that google offers this military/24hr time format. You could add a clock device to the existing script to have it add to the time format or adjust the regexpression but is not something I wish to pursue for mine script. What you make of my script can be anything you wish. The code is there... Enjoy! :)

Link to comment
Share on other sites

  • 3 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...