timezone

By alch3my on May 20, 2009

I originally created this for my bot, so people could store their local timezones into the bot, and it would remember them for future references in case someone wanted to find out the current time for that particular person if they weren't online.

The snippet supports the following timezones:
ACDT ACST ADT AEDT AEST AHST AKDT AKST AST AT AWDT AWST BST BT CAT CCT CDT CEDT CEST
CET CST CXT DST EEDT EEST EET EST GMT GST HST IDLE IDLW IST JST MDT MSD MSK MST NDT
NFT NST NT NZST PDT PST UT UTC WAT WEDT WEST WET WST YST

It's my first attempt at a timezone snippet, so be gentle! ;)

Usage: /tzone <#channel> --- #channel is optional, will echo if left out.

or, in the bot as: on :TEXT:!tzone:#:tzone $2 $chan

A few examples (without channel):

/tzone CST+0.25
CST+0.25 [Central Standard Time] 00:55 @ Wed 20th May [GMT -5.75]

/tzone GMT+8
GMT+8 [Greenwich Mean Time] 14:40 @ Wed 20th May

/tzone JST
JST [Japan Standard Time] 15:45 @ Wed 20th May [GMT +9]

/tzone ACST-1
ACST-1 [Australia Central Standard Time] 15:20 @ Wed 20th May [GMT +8.5]

/tzone +9
GMT+9 [Greenwich Mean Time] 16:44 @ Wed 20th May

/tzone noidea
Unknown Timezone Format - Defaulting to GMT..
GMT [Greenwich Mean Time] 07:31 @ Wed 20th May

alias tzone {
  var %w = -12&-11&-10&-10&-10&-9&-9&-8&-8&-7&-7&-6&-6&-5&-5&-4&-3.5&-3&-2.5&-2&-1&+12&+12&11.5&+11&+10.5&+10&+10&+9.5&+9&+9&+8&+8+8&&+7&+4&+3&+3&+3&+3&+2&+2&+2&+1&+1&+1&+1&+1&+1&0&0&0&0
  var %x = IDLW NT HST CAT AHST YST AKST PST AKDT PDT MST MDT CST EST CDT AST NST ADT NDT AT WAT IDLE NZST NFT AEDT ACDT AEST GST ACST AWDT JST AWST CCT WST CXT MSD MSK BT EEDT EEST EET CEDT CEST CET DST BST IST WEDT WEST WET UTC UT GMT
  var %y = International Date Line West.Nome.Hawaii Standard.Central Alaska.Alaska-Hawaii Standard.Yukon Standard.Alaska Standard.Pacific Standard.Alaska Daylight.Pacific Daylight.Mountain Standard.Mountain Daylight.Central Standard.Eastern Standard.Central Daylight.Atlantic Standard.Newfoundland Standard.Atlantic Daylight.Newfoundland Daylight.Azores.West Africa.International Date Line East.New Zealand Standard.Norfolk Island.Australian Eastern Daylight.Australian Central Daylight.Australian Eastern Standard.Guam Standard.Australia Central Standard.Australian Western Daylight Time.Japan Standard.Australian Western Standard.China Coast.Western Standard.Christmas Island.Moscow Daylight.Moscow Standard.Baghdad.Eastern European Daylight.Eastern European Summer.Eastern European.Central European Daylight.Central European Summer.Central European.Daylight Saving.British Summer.Irish Summer.Western European Daylight.Western European Summer.Western European.Universal Co-ordinated.Universal.Greenwich Mean
  if (!$istok(%x,$alpha($1),32)) { $iif(!$isin($left($1,1),+ -),.msg $2 Unknown Timezone Format - Defaulting to GMT..) | tokenize 32 $+(GMT,$iif($isin($left($1,1),+ -),$1,$+($v1,$gettok($1,2,$asc($v1))))) $2 }
  var %zone = $gettok(%y,$findtok(%x,$alpha($1),1,32),46), %gmt = $iif($calc($gettok(%w,$findtok(%x,$alpha($1),1,32),38) $iif($isin($1,+ -),$v1 $gettok($1,2,$asc($v1)))) > -1,$+($chr(43),$v1),$v1)
  var %time = $calc($gmt $left(%gmt,1) (($remove($gettok(%gmt,1,46),$chr(43),$chr(45)) * 60 * 60) + $iif($numtok(%gmt,46),$calc(60 * $+($chr(46),$gettok(%gmt,2,46)))) * 60)) )
  $iif($2,.msg $2,echo -a) $1 $+($chr(91),$addtok(%zone,Time,32),$chr(93)) $asctime(%time,HH:nn) @ $asctime(%time,ddd ddoo mmm) $iif($alpha($1) != GMT,$+($chr(91),GMT %gmt,$chr(93)))
}

alias -l isin { var %n = $numtok($2-,32) | while (%n) { if ($gettok($2-,%n,32) isin $1) { return $v1 } | dec %n } }
alias -l alpha { var %a = $len($1), %b = 1, %z | while (%b <= %a) { var %v = $mid($1,%b,1) | if (%v !isalpha) { return %z } | var %z = $+(%z,$mid($1,%b,1)) | inc %b } | return $1 }

Comments

Sign in to comment.
Arrow | irc.torn.com   -  Feb 15, 2016

Doesn't include SAST (South Africa Standard Time)

added to include:
var %w = -12&-11&-10&-10&-10&-9&-9&-8&-8&-7&-7&-6&-6&-5&-5&-4&-3.5&-3&-2.5&-2&-1&+12&+12&11.5&+11&+10.5&+10&+10&+9.5&+9&+9&+8&+8+8&&+7&+4&+3&+3&+3&+3&+2&+2&+2&+2&+1&+1&+1&+1&+1&+1&+1&0&0&0&0

var %x = IDLW NT HST CAT AHST YST AKST PST AKDT PDT MST MDT CST EST CDT AST NST ADT NDT AT WAT IDLE NZ NZST NFT AEDT ACDT AEST GST ACST AWDT JST AWST CCT WST CXT MSD MSK BT EEDT EEST EET SAST CEDT CEST CET BEL DST BST IST WEDT WEST WET UTC UT GMT
var %y = International Date Line West.Nome.Hawaii Standard.Central Alaska.Alaska-Hawaii Standard.Yukon Standard.Alaska Standard.Pacific Standard.Alaska Daylight.Pacific Daylight.Mountain Standard.Mountain Daylight.Central Standard.Eastern Standard.Central Daylight.Atlantic Standard.Newfoundland Standard.Atlantic Daylight.Newfoundland Daylight.Azores.West Africa.International Date Line East.New Zealand.New Zealand Standard.Norfolk Island.Australian Eastern Daylight.Australian Central Daylight.Australian Eastern Standard.Guam Standard.Australia Central Standard.Australian Western Daylight Time.Japan Standard.Australian Western Standard.China Coast.Western Standard.Christmas Island.Moscow Daylight.Moscow Standard.Baghdad.Eastern European Daylight.Eastern European Summer.Eastern European.South Africa Standard.Central European Daylight.Central European Summer.Central European.Belgium.Daylight Saving.British Summer.Irish Summer.Western European Daylight.Western European Summer.Western European.Universal Co-ordinated.Universal.Greenwich Mean

 Respond  
celien   -  Nov 09, 2010

great script was gonna create something like that but thought i swing by here first and yay!

 Respond  
meluygas   -  Jul 28, 2010

Jethro_ thanks for answering those days had a problem with the server justin.tv I grab them and I can not put the bot on other channels you know anything about that? and the other question is how do I q the bot has an option for repeat q different answers on occasions such as: on 1: TEXT:! joke *: # (/ describe $ chan [bot] ► brut was so gross when the teacher erased the task in the l erased the blackboard in the notebook .. Q) but assuming you another joke as I do for q below the alternatives? ... Thanks and greetings:)

 Respond  
Jethro   -  Jul 20, 2010

The first step is to read mIRC's help file, experiment and practice. if stuck, post your code and ask for help and learn from it.

 Respond  
meluygas   -  Jul 20, 2010

hola q tal soi from Argentina and I'm just starting with mirc if you need help and cooperation could help me be the moleataria agradeceria not much I would like to know about the basic commands for the bot .. :) Thank you very much

 Respond  
Jethro   -  Jul 20, 2010

meluygas, write it in English please.

 Respond  
meluygas   -  Jul 19, 2010

hola q tal soy de argentina y recien estoy comenzando con el mirc y nececito ayuda si ustedes me prodrian ayudar se los agradeceria no los moleataria mucho me gustaria saber sobre los comandos basicos para el bot .. :) muchas gracias

 Respond  
Amiga600   -  Jul 16, 2010

This was extremely useful, Thanks for making it.

 Respond  
Ash44455666   -  Jun 24, 2009

Spectacular! This was EXACTLY what I was looking for. I had to make 1 or 2 tweaks, but other than that it's perfect. Thanks a lot!

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.