collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18365
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Time (modified, with timezones data hacked out of IGN)  (Read 8718 times)

0 Members and 1 Guest are viewing this topic.

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Time (modified, with timezones data hacked out of IGN)
« on: March 16, 2006, 12:24:23 am »
Another case of me missing a plugin from IGN, so I dove into time.php from bebot and bot.php from IGN and went to work with a pair of pliars and a blowtorch.

I hope someone finds this useful.
Suggestions are of course, welcome.

Code: [Select]
<?php
/*
* Time.php - Displayes GMT time.
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
*
* Developed by Blondengy (RK1)
* Special thanks goes out to Khalem (RK1) for his support.
*
* File last changed at $LastChangedDate: 2005-12-13 01:34:04 +0100 (Tue, 13 Dec 2005) $
* Revision: $Id: Time.php 37 2005-12-13 00:34:04Z shadowmaster $
* Added Timezone display support (borrowed heavily from IGN) - Zakus RK1 - 03/15/2006
*/


$time = new ShowTime($bot);

$commands["tell"]["time"] = &$time;
$commands["pgmsg"]["time"] = &$time;
$commands["gc"]["time"] = &$time;




/*
The Class itself...
*/
class ShowTime
{
var $bot;



/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function ShowTime (&$bot)
{
$this -> bot = &$bot;
}



/*
This gets called on a tell with the command
*/
function tell($name$msg)
{
$this -> bot -> send_tell($name$this -> make_time());
}



/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name$msg)
{
$this -> bot -> send_pgroup($this -> make_time());
}



/*
This gets called on a msg in the guildchat with the command
*/
function gc($name$msg)
{
$this -> bot -> send_gc($this -> make_time());
}



/*
Makes time...
*/
function make_time()
{
$time["GMT"]="Greenwich Mean Time <font color=CCInfoHeadline>(GMT / AO)</font> is ".gmdate("g:i A");
$time["NST"]="Newfoundland Standard Time <font color=CCInfoHeadline>(GMT-3:30)</font> is ".gmdate("g:i A",time()-12600);
$time["AST"]="Atlantic Standard Time (<font color=CCInfoHeadline>GMT-4)</font> is ".gmdate("g:i A",time()-(3600*4));
$time["EST"]="Eastern Standard Time <font color=CCInfoHeadline>(GMT-5)</font> is ".gmdate("g:i A",time()-(3600*5));
$time["CST"]="Central Standard Time <font color=CCInfoHeadline>(GMT-6)</font> is ".gmdate("g:i A",time()-(3600*6));
$time["MST"]="Mountain Standard Time <font color=CCInfoHeadline>(GMT-7)</font> is ".gmdate("g:i A",time()-(3600*7));
$time["PST"]="Pacific Standard Time <font color=CCInfoHeadline>(GMT-8)</font> is ".gmdate("g:i A",time()-(3600*8));
$time["AKST"]="Alaska Standard Time <font color=CCInfoHeadline>(GMT-9)</font> is ".gmdate("g:i A",time()-(3600*9));
$time["HAST"]="Hawaii-Aleutian Standard Time <font color=CCInfoHeadline>(GMT-10)</font> is ".gmdate("g:i A",time()-(3600*10));
$time["NDT"]="Newfoundland Daylight Time <font color=CCInfoHeadline>(GMT-2:30)</font> is ".gmdate("g:i A",time()-9000);
$time["ADT"]="Atlantic Daylight Time <font color=CCInfoHeadline>(GMT-3)</font> is ".gmdate("g:i A",time()-(3600*3));
$time["EDT"]="Eastern Daylight Time <font color=CCInfoHeadline>(GMT-4)</font> is ".gmdate("g:i A",time()-(3600*4));
$time["CDT"]="Central Daylight Time <font color=CCInfoHeadline>(GMT-5)</font> is ".gmdate("g:i A",time()-(3600*5));
$time["MDT"]="Mountain Daylight Time <font color=CCInfoHeadline>(GMT-6)</font> is ".gmdate("g:i A",time()-(3600*6));
$time["PDT"]="Pacific Daylight Time <font color=CCInfoHeadline>(GMT-7)</font> is ".gmdate("g:i A",time()-(3600*7));
$time["AKDT"]="Alaska Daylight Time <font color=CCInfoHeadline>(GMT-8)</font> is ".gmdate("g:i A",time()-(3600*8));
$time["HADT"]="Hawaii-Aleutian Daylight Time <font color=CCInfoHeadline>(GMT-9)</font> is ".gmdate("g:i A",time()-(3600*9));
$time["WET"]="Western European Time <font color=CCInfoHeadline>(GMT)</font> is ".gmdate("g:i A");
$time["CET"]="Central European Time <font color=CCInfoHeadline>(GMT+1)</font> is ".gmdate("g:i A",time()+3600);
$time["EET"]="Eastern European Time <font color=CCInfoHeadline>(GMT+2)</font> is ".gmdate("g:i A",time()+(3600*2));
$time["WEST"]="Western European Summer Time <font color=CCInfoHeadline>(GMT+1)</font> is ".gmdate("g:i A",time()+3600);
$time["CEST"]="Central European Summer Time <font color=CCInfoHeadline>(GMT+2)</font> is ".gmdate("g:i A",time()+(3600*2));
$time["EEST"]="Eastern European Summer Time <font color=CCInfoHeadline>(GMT+3)</font> is ".gmdate("g:i A",time()+(3600*3));
$time["AWST"]="Western Standard Time <font color=CCInfoHeadline>(GMT+8)</font> is ".gmdate("g:i A",time()+(3600*8));
$time["ACST"]="Central Standard Time <font color=CCInfoHeadline>(GMT+9:30)</font> is ".gmdate("g:i A",time()+(3600*9.5));
$time["AEST"]="Eastern Standard Time <font color=CCInfoHeadline>(GMT+10)</font> is ".gmdate("g:i A",time()+(3600*10));
$time["AWDT"]="Western Daylight Time <font color=CCInfoHeadline>(GMT+9)</font> is ".gmdate("g:i A",time()+(3600*9));
$time["ACDT"]="Central Daylight Time <font color=CCInfoHeadline>(GMT+10:30)</font> is ".gmdate("g:i A",time()+(3600*10.5));
$time["AEDT"]="Eastern Daylight Time <font color=CCInfoHeadline>(GMT+11)</font> is ".gmdate("g:i A",time()+(3600*11));
$time["HON"]="Hong Kong Time - China <font color=CCInfoHeadline>(GMT+8)</font> is ".gmdate("g:i A",time()+(3600*8));
$time["BAN"]="Bankok Time - Thailand <font color=CCInfoHeadline>(GMT+7)</font> is ".gmdate("g:i A",time()+(3600*7));
    
$time["JAK"]="Jakarta Time - Indonesia <font color=CCInfoHeadline>(GMT+7)</font> is ".gmdate("g:i A",time()+(3600*7));
$time["KUW"]="Kuwait Time <font color=CCInfoHeadline>(GMT+3)</font> is ".gmdate("g:i A",time()+(3600*3));


$worldtime="WORLD TIMEZONES \n".
"Timetable for " gmdate("M j, Y, G:i") . " (GMT / AO) \n\n".
"<font color=#ffffff>US PACIFIC:</font>\n\n".
"  "."<font color=CCInfoHeader>Winter offset:</font>\n".
"     "."<font color=#ffffff>| NST    ".$time["NST"]."</font>\n".
"     "."<font color=#ffffff>| AST    ".$time["AST"]."</font>\n".
"     "."<font color=#ffffff>| EST    ".$time["EST"]."</font>\n".
"     "."<font color=#ffffff>| CST    ".$time["CST"]."</font>\n".
"     "."<font color=#ffffff>| MST    ".$time["MST"]."</font>\n".
"     "."<font color=#ffffff>| PST    ".$time["PST"]."</font>\n".
"     "."<font color=#ffffff>| AKST  ".$time["AKST"]."</font>\n".
"     "."<font color=#ffffff>| HAST  ".$time["HAST"]."</font>\n".
"  "."<font color=CCInfoHeader>Summer offset:\n".
"     "."<font color=#ffffff>| NDT    ".$time["NDT"]."</font>\n".
"     "."<font color=#ffffff>| ADT    ".$time["ADT"]."</font>\n".
"     "."<font color=#ffffff>| EDT    ".$time["EDT"]."</font>\n".
"     "."<font color=#ffffff>| CDT    ".$time["CDT"]."</font>\n".
"     "."<font color=#ffffff>| MDT    ".$time["MDT"]."</font>\n".
"     "."<font color=#ffffff>| PDT    ".$time["PDT"]."</font>\n".
"     "."<font color=#ffffff>| AKDT  ".$time["AKDT"]."</font>\n".
"     "."<font color=#ffffff>| HADT  ".$time["HADT"]."</font>\n\n".
"<font color=#ffffff>EUROPE:</font>\n\n".
"  "."<font color=CCInfoHeader>Winter offset:</font>\n".
"     "."<font color=#ffffff>| WET   ".$time["WET"]."</font>\n".
"     "."<font color=#ffffff>| CET   ".$time["CET"]."</font>\n".
"     "."<font color=#ffffff>| EET    ".$time["EET"]."</font>\n".
"  "."<font color=CCInfoHeader>Summer offset:</font>\n".
"     "."<font color=#ffffff>| WEST ".$time["WEST"]."</font>\n".
"     "."<font color=#ffffff>| CEST  ".$time["CEST"]."</font>\n".
"     "."<font color=#ffffff>| EEST   ".$time["EEST"]."</font>\n\n".
"<font color=#ffffff>AUSTRALIA:</font>\n\n".
"  "."<font color=CCInfoHeader>Winter offset:</font>\n".
"     "."<font color=#ffffff>| AWST ".$time["AWST"]."</font>\n".
"     "."<font color=#ffffff>| ACST  ".$time["ACST"]."</font>\n".
"     "."<font color=#ffffff>| AEST  ".$time["AEST"]."</font>\n".
"  "."<font color=CCInfoHeader>Summer offset:</font>\n".
"     "."<font color=#ffffff>| AWDT ".$time["AWDT"]."</font>\n".
"     "."<font color=#ffffff>| ACDT  ".$time["ACDT"]."</font>\n".
"     "."<font color=#ffffff>| AEDT  ".$time["AEDT"]."</font>\n\n".
"<font color=#ffffff>ASIAN PACIFIC / MIDDLE EAST:</font>\n\n".
"     "."<font color=#ffffff>| HON     ".$time["HON"]."</font>\n".
"     "."<font color=#ffffff>| BAN     ".$time["BAN"]."</font>\n".
"     "."<font color=#ffffff>| JAK     ".$time["JAK"]."</font>\n".
"     "."<font color=#ffffff>| KUW    ".$time["KUW"]."</font>\n";


return "Greenwich Mean Time (GMT / AO) is <font color=#ffff00>" gmdate("H:i") . "</font>  :: " $this -> bot -> make_blob("click for timezones"$worldtime);
}
}
?>


Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #1 on: March 16, 2006, 12:43:21 am »
There's something wrong with it :)

I think instead of using time(), you need like gmtime() if there is one.

Issue is that it's based from "that" server which hosts the bot.

Will do more work on it later (going out for awhile atm :P)
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #2 on: March 16, 2006, 12:51:47 am »
I thought it was getting it via gmdate, I'll defer to your smartness though :)

MatHack

  • Guest
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #3 on: March 16, 2006, 01:34:35 am »

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #4 on: March 16, 2006, 05:27:03 am »
If time() is GMT then a calculation is wrong.

GMT 7pm is 2pm EST, on the !time, it shows as 9am.

I'll try fiddling with it.
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #5 on: March 16, 2006, 05:45:48 am »
Looked into it a bit.

Timetable for Mar 16, 2006, 0:40 (GMT / AO) according to !time
UTC: Thu Mar 16 04:40:27 2006 according to AO (which is real GMT)

Would the server timestamps affect the gmdate?
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #6 on: March 16, 2006, 10:31:30 am »
I copied and pasted that code as is up there and all times are reported properly by the bot on my server located in MST.

*shrug* works for me.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #7 on: March 16, 2006, 05:19:26 pm »
Hrm, that's really weird...

I'll check to see if it's my server then :P
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #8 on: March 16, 2006, 07:49:11 pm »
What's your clock set too? Most unix systems set the hardware clock to GMT/UTC, and use an environment setting to output the right time. Not sure what windows does, and if PHP covers those problems. Just throwing out thoughts here though :)

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #9 on: March 16, 2006, 08:14:55 pm »
My clock is set to local time (GMT-7)
On a windows XP pro box.
Running the php.exe that came with bebot.

(If that helps any)

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #10 on: March 16, 2006, 08:17:39 pm »
It's a linux system, and it says it's set to GMT/UTC.

Maybe I'll have to set the clock manually instead.
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline porter

  • BeBot User
  • **
  • Posts: 28
  • Karma: +0/-0
Re: Time (modified, with timezones data hacked out of IGN)
« Reply #11 on: March 17, 2006, 05:20:58 pm »
If time() is GMT then a calculation is wrong.

GMT 7pm is 2pm EST, on the !time, it shows as 9am.

Just an observation: 2pm EST +5 is 7pm while 2pm EST -5 would be 9am. Any chance there is a typo in your version where a plus went minus?

 

* Recent Posts
0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm ]

* Who's Online
  • Dot Guests: 155
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal