Author Topic: Request: Timezone Converter  (Read 3658 times)

Inkpot

  • Newbie
  • *
  • Posts: 7
Request: Timezone Converter
« on: March 28, 2010, 09:25:06 AM »
Hello all,

I regularly frequent a channel with many international members and trying to schedule things that take into account the many varying timezones can be rather confusing. I was wondering if there was a way to create a script that would automagically convert a time in one timezone to a time in another? What I envision is something like this:

[Inkpot] /tzconvert 9:15am PST (to) GMT

And then the script would return:

*9:15am PST --> 4:15pm GMT


Of course, the script would have to take into account all the various timezones, and if the result lands on the following day, it would specify that as well. This sounds like it would be really, really complicated (impossible?) to do - but then again, I'm not an IRC superhero like some of you here. :P

What do you think?


Inkpot

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: Request: Timezone Converter
« Reply #1 on: March 28, 2010, 12:47:11 PM »
That shouldn't be too hard.

Just make a list of timezones. An ini file would probably be the easiest way

Code: [Select]
[Zone]
UTC=0
CET=1
EET=2
.
.
.

Then just read the values for both timezones, add them together and add that number to the time passed to the script in the first place. Then if the hour is 12, switch from am to pm and if it's greater than 12 also subtract 12 (and the other way around if the time becomes negative). Or for 24h time, if the time is greater than 24 subtract 24.

You could also make it recognize countries instead of timezones, which would allow you to take daylight saving times into account.

Lots of good stuff about timezones and such on wikipedia
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Inkpot

  • Newbie
  • *
  • Posts: 7
Re: Request: Timezone Converter
« Reply #2 on: March 28, 2010, 01:22:27 PM »
Heheh....did I fail to mention that I'm horrible at scripting? I was hoping someone could cook one up for me. Anyone willing?


Inkpot

Inkpot

  • Newbie
  • *
  • Posts: 7
Re: Request: Timezone Converter
« Reply #3 on: April 01, 2010, 07:32:20 AM »
Aww...no one willing to tackle this one? I'd really appreciate it...right now, it's beyond my capabilities... :-(

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Request: Timezone Converter
« Reply #4 on: April 01, 2010, 10:19:57 AM »
Well, to start with, it would be easier to start it with using a 24 hour clock, and then after you get that working, convert it to the am/pm format.

The other issue is, daylight savings, that's what makes it messy.  What you first need to do is get all the time zone values, and place them either in an INI file or just in the script itself. Then you need to determine the daylight savings values for each time zone.

If you have absolutely zero scripting experience, then you will just need to wait for someone to write this for you, and then hopefully it will serve as a learning experience for you.
The IceChat God

Inkpot

  • Newbie
  • *
  • Posts: 7
Re: Request: Timezone Converter
« Reply #5 on: April 02, 2010, 08:43:01 AM »
Thanks, Snerf. Yes, right now I have zero scripting experience. I've been reading the tutorials, etc...but am still very much a newbie. Hopefully, someone will be interested enough to write it for me and then I can dissect it. :)