Help with a world time clock?
February 10, 2004 9:16 AM   Subscribe

World clocks. I am trying to put together a clock application and can't work out how to discern the actual time is in each city. The time zone part is easy, but a great many countries (most?) use seasonal time adjustments. I have an online world clock on my screen and a physical one hanging above my head. How do they work?
posted by elliot100 to Computers & Internet (4 answers total)
 
I ran into this problem while working on an application a while back; This was perl on unix, and after a few attempts to actually program it myself, I realised I could just (ab)use the library infrastructure that was there by setting the environment variable TZ (this specifies the timezone to libc) to the zone I wanted to convert from/to, and using localtime and gmtime.

Slightly more generally, every time standard consists of a few parameters, mainly offset to UTC and daylight savings time start/end. Given these parameters you can always compute the local time from UTC. If you don't want to punch in all this data yourself, either grab it from a piece of software like glibc, or just pull it from the OS you're using; Windows, MacOS and Unices all have conversion routines somewhere.
posted by fvw at 9:35 AM on February 10, 2004


Thanks. I have to admit I am not a programmer as such and didn't realise it was all built in. I'd just assumed from the start that seasonal time changes were movable feasts. No need to reinvent the wheel then. The clock as it stands is here, by the way.
posted by elliot100 at 10:24 AM on February 10, 2004


Are you thinking of something like this?
posted by Vidiot at 10:27 AM on February 10, 2004


Note that though they're there, they're not necessarily exposed or intended for your use. As said, I had to use a (not thread-safe) kludge to use the libc one, don't know what's possible with windows or MacOS 9.
posted by fvw at 10:28 AM on February 10, 2004


« Older How Can I Ship a Family Antique Cross-Country?   |   Does anyone have experience creating their own... Newer »
This thread is closed to new comments.