Looking for World Time ApplicationForum: Apps Topic: Looking for World Time Application started by: Juanito Posted by Juanito on Sep. 23 2007,11:40
I'm looking for an application that displays the time in several locations - preferably analogue clocks that show the time in London, New York, Toyko, etc - that I can make into a mydsl extension.So far, I've come across gworldtime but that requires gtk+2.0. Does anybody know of a suitable application that uses gtk+1.2 or other base dsl libs? Could torsmo be used for this purpose? Posted by mikshaw on Sep. 23 2007,13:04
It could be made very easily with murgaLua.I just woke up, so I'm in no condition to do it or show how to do it at the moment, but it probably shouldn't take more than a few minutes to put something like that together. Of course it would depend on whether or not you want it to actively retreive the time from a server (probably need additional software?), or just set an offset for each clock using your system time. Posted by Juanito on Sep. 23 2007,13:53
It'd take me more than a few minutes to put something together There's already a timeserver script in dsl (somewhere), but in my case an offset from the local time would probably be best as my time zone (GMT+4) is not in the dsl subset of time zones. Posted by WDef on Sep. 23 2007,14:44
More perl practice. You could call something like this and display its output in torsmo:
NB: there is a notice in the TimeAndDate html source saying that programs that download content "transparent to the user" are forbidden. Hence the output informing of the download in the above. But if there's any call for it, this could be adapted to pull time off some other page not having restrictions. EDIT: added argument check. Posted by Juanito on Sep. 23 2007,15:04
Impressive - and to have it in 24:00 format? Posted by WDef on Sep. 23 2007,15:29
Some more perl could convert to 24 hr format (might try it), but it might be lazier to call the system's date command from within perl to convert times.There's zdump, if you know the desired timezone, eg EST:
but this seems to be giving wrong answers on dsl. Locale issues? Posted by WDef on Sep. 23 2007,16:11
With 24-hr output and taking multiple city arguments:EDIT: added -f option to access extended listing of city times, useage -h EDIT2&3: now outputs 5-char time in justified columns for tidy display. Set width with option -w EDIT4: Web source is www.whatisthetime.com. -f switch has no effect for this.
Posted by mikshaw on Sep. 23 2007,16:30
Wow. I'm glad you did that, because I already spent much more than a few minutes on it before remembering things like DST...which would mean much more work than I even want to consider bothering with =o)
Posted by Juanito on Sep. 23 2007,17:36
Now I'm well impressed - let's see if I can get this into torsmo Posted by Juanito on Sep. 24 2007,11:07
So, I added this to the end of .torsmorc:
But, since it starts off with:
The torsmo display gets v-e-r-y w-i-d-e... I guess for this to progress, I'd need a site that didn't require the url to be stated. Posted by mikshaw on Sep. 24 2007,14:01
I assume you would be allowed to format the outpoot slightly if it's causing display troubles. The timeanddate people would have to be mightily spitely to have a problem with that. Try just inserting a newline:
The information remains unchanged, but your display is not messed up. Posted by WDef on Sep. 24 2007,14:04
Juanito: Did you notice I've added a width control switch to citytime.pl with some other stuff?Eg set 20 chars output width before 5-char time is displayed (so total width is 25 chars):
Also, the data is now justified uniformly. You have Tokyo printed out twice; I'm doing (eg):
Mikshaw: I've shortened the message to the minimum:
Another source might be nice - some of these have additional info eg weather. I'm only guessing it is necessary to flag the source to the user. It is not clear to me and I'm not a lawyer. There's no EULA on the web site that I can find, and I am wondering if they could enforce rights over "the time", public domain data if ever there was any. Their notice is not in plain view - it is buried in the html source. And just how do they prevent people from accessing the web page data using whatever technology they feel like? Tell them it's "forbidden?" Posted by Juanito on Sep. 24 2007,15:19
One way around it could be to comment out the url in citytime.pl and use something like this in torsmorc:
On a minor level, aesthetically it might be better to put the time first (with a leading zero if required) or align the time output, but that's just splitting hairs. Posted by WDef on Sep. 24 2007,15:35
You need to try the 'latest version' - I updated it already to add leading zeroes and to justify columns, and to check args and options.For me, torsmo is looking very good without multiple calls to citytime.pl (means multiple downloads). No need to comment out the (shortened) message. Also, have changed the source to < www.whatisthetime.com > , which does not seem to have evil notices anywhere that I can find, in case anyone is worried. The same regex worked on their list. Feedback about new server speed of download etc? Posted by Juanito on Sep. 24 2007,17:15
- We must have been typing the last posts at the same time. This seems to do the trick now:
About the only thing I notice (and it was the same for both url's) is that torsmo is very slow to start now and blinks occasionally (but I did see something about double-buffering somewhere). Thanks - learnt something more there, now I'm going to try at adding some cpu info, etc to the display. Posted by WDef on Sep. 24 2007,18:26
Actually it's been handy for me as I find the city/time display quite useful, so thanks Juanito for the impetus.My torsmo was taking a second or two to start anyway, maybe coz I have acpi temp etc displayed. May try to expand what it can pull in at the same time by using a different site containing more info - maybe display city temperature? Wonder if that would be interesting. Might make torsmo display 5 chars wider if on the same line as time. Posted by mikshaw on Sep. 24 2007,20:33
After waking up it occured to me that you cannot be forced to display credits on your own machine. I can maybe understand requiring it in distributed applications that use your service, but if that application is open the end users can modify it themselves to remove that credit.After the information arrives at its intended destination the service provider has no say in how that info is used. After all the info itself is not property. Posted by WDef on Sep. 24 2007,21:28
Makes sense. I think timeanddate.com's notice (doesn't actually say anything as speciific as they 'must be acknowledged') would be a lot less feeble, and more visible, if they thought they had a chance of enforcing it. I don't mind acknowledging a free source - that is what they should specifically ask for. torsmo starts slowly for me with or without this perl code. Does torsmo just start slower when you load it with *any* script? And this double buffering thing ..? Thinking about ways to speed up citytimes.pl eg 1. Don't download every single call. Instead, store the times and increment from the system clock, do correction from the web every hour or so. Needs to get seconds as well to do this. 2. Don't download a full page every time. Instead, parse the page on the fly while it downloads, stop downloading as soon as required info is received. 3. Make web page grepping more efficient (not much benefit). Posted by Juanito on Sep. 25 2007,03:36
- For me this would be the way to go, with the added bonus that your machine's time zone does not need to be set correctly (I cannot set mine in dsl). I left citytime/torsmo running over night and this morning there was just the url and no times displayed - I suppose the net connection dropped out at some point and stopped things working. If you go with the web correction method then I guess it could be programmed to do nothing if it cannot connect. Posted by WDef on Sep. 25 2007,12:36
I'll give this is go in the next few days.The time display vanished for me also when left running overnight. Posted by WDef on Oct. 01 2007,20:40
Here's a better rendition, makes config file ~/.citytimerc, updates betweeen downloads using the system clock, etcWidth is now the total width.
Posted by Juanito on Oct. 04 2007,14:50
Looks good so far.I changed the .torsmorc line to read "execi 60" so that the times read the same as the system clock. Torsmo takes 100s to appear on my (slow) machine versus almost immediately without the .citytime call - it was probably as slow with the previous incarnations of .citytime. Posted by WDef on Oct. 04 2007,15:20
It has to download the times page the first time it is run after bootup, that's going to slow things down. I start my network connection after starting the desktop, so don't notice this. Is this what the holdup is?If you quit X and restart, it won't download again until the $download_interval period is up or something's happened to the cache or temp files etc. (Doing this on my 1.87Ghz machine, torsmo starts after about 3 sec, and I'm running several other scripts, hacks etc as well from it). So that'll tell us if it's the download or something else holding up torsmo for you. The torsmo config file does say that running external stuff from torsmo in this way consumes a lot of resources. How's the blinking? For me it's much improved, and seems to be coming from the other extra stuff I'm having torsmo do anyway. I also use execi 60 - makes sense to refresh the minutes display every minute. Posted by Juanito on Oct. 04 2007,15:32
If I exit and then (re)startx, the torsmo display takes about 20s to appear and the world time digital clocks about 20s after that - this is on a 267MHz Pentium II...I would say the blinking is about the same with/without .citytime Posted by WDef on Oct. 04 2007,16:25
I could add an option to disable arg and local dst status checking, that would make no difference on my 1.87Ghz machine but might on yours. If you say the previous citytime was just as slow, this isn't the problem anyway.It seems to be taking a long time just to parse the cache file and update the times display on your machine, which is almost instantaneous on my machine. If I knew more perl, I could probably make it run much faster. It's not helped by calling system progs like wget as child processes - a workaround because dsl lacks the standard LWN::Simple module (contains perl's 'get'). A lua version probably would go faster, but might still need to drop to perl/sed/awk in order to extract the times from the html. In case anyone wants to write a version in another language, perl can be called from the shell to extract a time from the downloaded html file thusly:
But it could be that running external interpreters from torsmo like this is just not so wonderful in any case on low spec machines. Posted by Juanito on Oct. 04 2007,17:01
Don't get me wrong, I'm not complaining - I restart this machine once/twice a month
Posted by WDef on Oct. 04 2007,17:07
There's nothing like reliability!Actually I've taken to choking my CPU down to 800Mhz anyway, so the laptop runs much cooler. Has no effect on citytime. So if you ever "upgrade" to a PIII+, you can expect much quicker torsmo stuff. Posted by Juanito on Oct. 05 2007,05:35
...left it going all night, every so often the torsmo display disappears for 10-15s and then comes back - this doesn't seem to match the frequency at which .citytime checks the web time though...
Posted by WDef on Oct. 05 2007,23:19
If you're calling a number of different things from torsmo - here I'm guessing - but perhaps this occurs when a number of torsmo-initiated events occur at the same time.Perhaps try breaking the intervals between the different calls so these are not in lock step eg every 90 sec for one external event and every 60 sec for another so they can't coincide. And/or try disabling these and adding them back in one at a time until the behavior manifests? Posted by Juanito on Oct. 06 2007,03:59
The only other external call being made is .torsmo_ip - I'll offset the "execi 180" to something else as you suggest. The blanking also might be related to the cpu %load - I'll have a look at this.
Posted by WDef on Oct. 10 2007,15:08
I've been rewriting this in C. Preliminary tests running it from torsmo are very smooth, no blinking at all, even downloading every call (no caching yet). It forks a child and downloads the time in that, so it might be possible to make it so that citytime just carries on reading from cached times while a sluggish download is in progress, thus removing any additional interruption to the display caused by a download. I also tried doing this in perl, but forking in perl by itself slowed things down.Still more work to do, but an interesting little project. |