Author |
Message |
Steptoe
Involved
![Involved Involved](modules/Forums/images/ranks/4stars.gif)
![](modules/Forums/images/avatars/db59d0e0432a3ca97d73f.gif)
Joined: Oct 09, 2004
Posts: 293
|
Posted:
Tue Oct 04, 2005 2:57 am |
|
This code is part of a world time clock block. Currently it only shows UTC, I want it to work for Daylight savings. There are 12 daylight savings around the world. These are included in the code below.
Is anyone able to make a sql or add the mathmatical equations to the code?
Code:
$content.="<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" width=\"100%\"><tr>";
$content.="<td width=\"100%\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\"><tr>";
$content .= "<td><select name=\"city\" size=\"1\" onchange=\"updateclock(this);\">
<option value=\"\" selected>Time Zone UTC</option> ////Daylight Savings 2005
<option value=\"0\">London GMT</option> ////Euro Starts 27 Mar end 30 Oct
<option value=\"1\">Brussels </option> ////Euro Starts 27 Mar end 30 Oct
<option value=\"1\">Rome</option> ////Euro Starts 27 Mar end 30 Oct
<option value=\"1\">Warsaw</option> ////Euro Starts 27 Mar end 30 Oct
<option value=\"2\">Jerusalem </option> ////Israel Starts 1 Apr end 8 Oct
<option value=\"2\">Amman </option> ////Jordan Starts 30 Mar end 20 oct
<option value=\"2\">Sth Africa </option>
<option value=\"2\">Beirut </option> ////Lebanon Starts 26 Mar end 29 Oct
<option value=\"3\">Moscow </option> ////Russia starts 26 Mar end 29 Oct
<option value=\"3\">Riyadh </option>
<option value=\"4\">Abu Dhabi </option>
<option value=\"5\">Islamabad </option>
<option value=\"5.5\">New Delhi </option>
<option value=\"6\">Colombo </option>
<option value=\"7\">Bangkok </option>
<option value=\"8\">Beijing </option>
<option value=\"9\">Tokyo </option>
<option value=\"9\">Montevideo </option> //// Uruguay Starts 27 Mar end 27 mar
<option value=\"8\">Perth </option>
<option value=\"9.5\">Darwin CST </option> //// VIC, SA End 2 April Starts 30 Oct
<option value=\"10\">Sydney EST</option> //// ACT, NSW end 26 Mar Starts 30 Oct
<option value=\"10\">Tasmania </option> //// Tasmania Starts 2 Oct End 26 Mar
<option value=\"11\">Noumea EST</option>
<option value=\"12\">New Zealand</option> //// New Zealand end 19 Mar starts 1 Oct
<option value=\"-10\">Honolulu</option>
<option value=\"-9\">Alaska</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-8\">Vancouver PST</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-7\">Denver MST</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-6\">Nashville CST</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-5\">Montreal EST</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-4\">Bermuda</option>
<option value=\"-4\">Santiago </option> ////Chile,Paraguay end 13 Mar Starts 18 Sep
<option value=\"-3\">Buenos Aires</option>
<option value=\"-3\">Brasilia </option> //// Brazil end 20 Feb Starts 16 Oct
<option value=\"-2\">Greenland</option>
<option value=\"-1\">Azores</option></select></td>";
$content.="</tr><tr><td width=\"100%\" align=\"center\">";
$content.="<sc ript language=\"JavaS cript\">
if (document.all||document.getElementById)
document.write(' <span id=\"worldclock\" style=\"font:bold 12px Arial;\"></span><br>')
zone=0;
isitlocal=true;
ampm='';
function updateclock(z){
zone=z.options[z.selectedIndex].value;
isitlocal=(z.options[0].selected)?true:false;
}
function WorldClock(){
now=new Date();
ofst=now.getTimezoneOffset()/60;
secs=now.getSeconds();
sec=-1.57+Math.PI*secs/30;
mins=now.getMinutes();
min=-1.57+Math.PI*mins/30;
hr=(isitlocal)?now.getHours():(now.getHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24;
ampm = (hr > 11)?\"PM\":\"AM\";
statusampm = ampm.toLowerCase();
hr2 = hr;
if (hr2 == 0) hr2=12;
(hr2 < 13)?hr2:hr2 %= 12;
if (hr2<10) hr2=\"0\"+hr2
var finaltime=hr2+':'+((mins < 10)?\"0\"+mins:mins)+':'+((secs < 10)?\"0\"+secs:secs)+' '+statusampm;
if (document.all)
worldclock.innerHTML=finaltime
else if (document.getElementById)
document.getElementById(\"worldclock\").innerHTML=finaltime
else if (document.layers){
document.worldclockns.document.worldclockns2.document.write(finaltime)
document.worldclockns.document.worldclockns2.document.close()
}
setTimeout('WorldClock()',1000);
}
window.onload=WorldClock
</ s cript>";
$content.="</tr></table></td></tr></table>";
?>
|
|
_________________ My Spelling is NOT incorrect, it's Creative
Last edited by Steptoe on Thu Nov 10, 2005 1:49 pm; edited 1 time in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Steptoe
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 09, 2005 8:40 pm |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
64bitguy
The Mouse Is Extension Of Arm
![](modules/Forums/images/avatars/183ecd6a404a3683445de.gif)
Joined: Mar 06, 2004
Posts: 1164
|
Posted:
Wed Oct 26, 2005 1:10 am |
|
What you are asking for is more than what the solution was designed for. For example, please refer to the following:
http://www.developer.com/ws/proto/article.php/1567581 |
_________________ Steph Benoit
100% Section 508 and W3C HTML5 and CSS Compliant (Truly) Code, because I love compliance. |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Steptoe
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Oct 26, 2005 3:27 am |
|
Ok that is a bit over my head, From what I read between the lines on that link...
It is possible to do right?
There is another nuke time block that does daylight savings
Quote: |
/* Copyright (c) 2004 by Ernie Oporto */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Update to version 1.2 by Q at www.3c0x1.net */
/* Added the ability to use or ingnore Day Light Savings Time (DST) */
/* Updated to new sql layer */
/* Added alternate row colors for readability */
/* Added the configuration option to display 24 hour or 12 hour clock */
/* Added the config option for patchlevel 2.9+ or not (from Raven) */
/* Use http://timeanddate.com/worldclock/ to get time and DST info
|
I have spoken to these guys, that is a USAF servicemen site, I asked If they could 'blend' what I have, add the extra daylight savings zones info in the code above I have added to the code above to the db. The answer was "busy" So I asked if they minded if I managed to find someone to do so, would they mind? They do not object.
From this I deduce the block is possible.(?) It will be they only one of its type for Nuke, it would be a useful block for international sites.
I can see further possibilities over and above the initial block.. where like with sending a PM, one would be able to clk a members country, or name from there get their time zone from where they put GMT+ hrs or calling from their ip with a ip to country db, or Approve membership module where an added country is part of registration
I am way out of my depth here ok...I don't even know if what I said above is possible or thats how things work.
An architect may have an idea..but it is a waste of an idea without a good builder.
And I cant hit a nail straight |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
64bitguy
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Oct 27, 2005 3:32 am |
|
There will be a function that does something similar to this in the new CNBYA. Right now, even with all of the hard work, it still has issues. I'm glad it wasn't me that coded this new function because it looks like a monster. It keeps thinking that I'm -4 when I'm actually -5 (next Saturday -6) on the east coast... but alas, such is life... an hour late and a dollar short.
I wish you luck in coding this, as I tried to point out these kinds of auto time-zone DST things are a bitch. To top that off, the code will even be changing again because of the new USA DST issues.... God help us. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Steptoe
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Oct 27, 2005 4:56 am |
|
So it is possible but
u guys arnt good enough to do it
and then u tell someone like ME "I wish you luck in coding this" lol
just pulling your tit a little m8
Kiwi humour
Had a short exchange with a Swiiss guy, hes not a nuke coder, just into time stuff as a bit of a hobby...if he gets time he may have a look at it some time.
Basically there are 12 daylight saving zones around the world with diff dates/times
Forget the times, that gives an error of a couple hrs 2x a yr..can live with that
Then next problem is the dates change each yr as they are on things like 'last Sat of Oct' that could be simplified by updating date entries each yr like the ip to country db bases are...even so if they are not, it means the time will be out couple days each yr for each time zone.
At the moment the clock face part gets the time from the users machine.
Then to get the time for another zone it then compares that to gmt and either adds or minus a few hrs and shows that for the time zone the user wants to find out about and displys that beside their local time on the analog clock
I think...
Now if it could also check the date of the users machine, then if it matches between 2 dates in the block code or db and simply adds or subtracts an extra hr for that period to or from what it already currently shows.
So we end up with something like this (please forgive my amaterish code logic stuff)
Quote: | //// e.g. Israel Starts 1 Apr end 8 Oct
<option value=\"2\">Jerusalem </option>
if date on users machine is between 1 Apr 2005 8 Oct 2005
<option value=\"2 + 1\">Jerusalem </option>
And for Sth hemispere
//// New Zealand starts 1 Oct 2005 end 19 Mar 2006
<option value=\"12\">New Zealand</option>
if date on users machine is between 1 Oct 2005 end 19 Mar 2006
<option value=\"12 +1\">New Zealand</option>
|
Does that sound logical?
I wouldnt have a clue where to start to actually do the real code thu.
The dates could be changed in the block or db manually each yr
There is a whole lot of stuff further down in the current block that looks to me, like where it currently gets the users time then compares to gmt and calculates the other time zone the user is requesting. Could not the above be added to that?
Quote: |
....hr=(isitlocal)?now.getHours():(now.getHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24; .......
|
Even so...I have a gut feeling in the above logic I have missed something or a detail |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Wed Nov 02, 2005 3:28 pm |
|
It's much easier than that! I noticed my UserInfo block got messed up for 1 hour on 10/31 and went about "discovering" on my own. PHP actually allows for DST with this call: date('I',time()). So, I am adding a quick and dirty routine to my block in the next release, something like this:
$todayDST = date('I',time())*3600; // 2.1.3
$yesterdayDST = date('I',time()-86400)*3600; // 2.1.3
$Today = date('M d, Y',time()-$todayDST); // 2.1.3
$Yesterday = date('M d, Y',time()-86400-$yesterdayDST); // 2.1.3
Now the only code that I have to add is for checking the date between March and April or October and November. Then that will determine whether or not to add or subtract the 86400 seconds ! |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Steptoe
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Nov 02, 2005 4:19 pm |
|
That is way over my head.
Would I have to put these at the top of the block?
$todayDST
$yesterdayDST
$Today
$Yesterday
And where in the block would I put the above in your post to try it out? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Nov 02, 2005 7:02 pm |
|
date('I',time()) will return either a 1 or a 0 (zero), where 1 means DST and 0 means not. So,
$todayDST = date('I',time())*3600;
$yesterdayDST = date('I',time()-86400)*3600;
will either resolve to 0 or 3600 <- # seconds in 1 hour. So, you now have your 2 offsets. Depending on whether it's Spring or Fall will determine whether to +/- the 3600 from the current time value that you are using. I am changing this all into a function and will post it later tonight. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Steptoe
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Nov 02, 2005 7:28 pm |
|
I THINK I see where u are going with this...
"Depending on whether it's Spring or Fall " Im not sure if u have got this fully covered thu...Spring in the sth hemisphere...(Aussie, NZ, SAfrica) is sept/Oct and Autumn March April.
"I have a gut feeling in the above logic I have missed something or a detail"
I think that is what I may have been refering to in a post above.
So would that mean 2 function thingys, so if someone is in the Sth hemisphere and getting time for a nth hemisphere it would be the other way around?
May I also suggest, at this stage not to publish yet...what is being devaloped here is a bit of code, that as far as I know is quite advanced and unique in what it does.
I havnt been banging my head against a brick wall or sitting on my .....over the last 10 months or so...I have googled , forum searched portals not just nuke, but v bulliten and many, many others, downloaded heaps of stuff to look at and come up with occasional info but there is nothing around that works
Edit: the closest I did find was at http://www.3c0x1.net/ World_Clock in the downloads I will put it up at the url I PMed u at |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Nov 02, 2005 10:53 pm |
|
In March/April in the US we lose an hour so the routine will need to +3600. In October/November we gain the hour back so it will need to -3600. Yu would just make a similar adjustment based on your rules. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Steptoe
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 03, 2005 12:35 am |
|
"When in doubt lay it out" Something my old mans said to me yrs ago.
1/ I cant bloody code, my head doesnt work like yours
2/I know to finish my projects is no mean task.
3/ I dont expect something for nothing.
4/I dont know what the ethics are getting this done,
3/ So I must ass-u-me u like to see the colour of a man's money 1st. Personally I think in this case "why not"
4/I have no idea what sort of donation would be expected.
5/I have never used pay pal..Always sent cash thru...but to get from here to Pensivilania it takes about 2 weeks!
6/Talked to the missus, $100 NZ, think about $75 US..I realy dont know what it is worth to u to do, if u want them for here..
7/I dont want to donate so the whole world can see, but if couple your coder m8s knew thats ok.
8/Im not going to be around nuke much longer...im into parrots not websevers .....I have undertaken to go from starting a server to finishing a user friendly web site...I need to finish the project.
Ravan, what your site is to Nuke, Ours to the Kakariki is as important the the internatal Kakariki world. Except within the next 12 months we are going to be taking one of the most powerful and arogant NZ Government ministries... DoC
9/We like u are completly non profit and like you support expenses and hardware.
Well that pretty stiaight up, if u could give your heart a rub, and tell me if it is worth more than $75 us |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 03, 2005 12:55 am |
|
I will be going to bed in a few minutes. Let's continue this dialogue off-line via email. I will contact you later today. Thanks. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Steptoe
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 10, 2005 2:17 pm |
|
I have been playing with the code above....
and dont seem to be doing something right.
This is the code of the whole block....as u see it is a mix of code from other blocks/modules.
Can someone insert the code then I will check it.
Code:<?php
if (eregi("block-World_Time.php", $_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
global $prefix, $dbi;
$content.="<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" width=\"100%\"><tr>";
$content.="<td width=\"100%\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\"><tr>";
$content .= "<td><select name=\"city\" size=\"1\" onchange=\"updateclock(this);\">
<option value=\"\" selected>Time Zone UTC</option> ////Daylight Savings 2005
<option value=\"0\">London GMT</option> ////Euro Starts 27 Mar end 30 Oct
<option value=\"1\">Brussels </option> ////Euro Starts 27 Mar end 30 Oct
<option value=\"1\">Rome</option> ////Euro Starts 27 Mar end 30 Oct
<option value=\"1\">Warsaw</option> ////Euro Starts 27 Mar end 30 Oct
<option value=\"2\">Jerusalem </option> ////Israel Starts 1 Apr end 8 Oct
<option value=\"2\">Amman </option> ////Jordan Starts 30 Mar end 20 oct
<option value=\"2\">Sth Africa </option>
<option value=\"2\">Beirut </option> ////Lebanon Starts 26 Mar end 29 Oct
<option value=\"3\">Moscow </option> ////Russia starts 26 Mar end 29 Oct
<option value=\"3\">Riyadh </option>
<option value=\"4\">Abu Dhabi </option>
<option value=\"5\">Islamabad </option>
<option value=\"5.5\">New Delhi </option>
<option value=\"6\">Colombo </option>
<option value=\"7\">Bangkok </option>
<option value=\"8\">Beijing </option>
<option value=\"9\">Tokyo </option>
<option value=\"9\">Montevideo </option> //// Uruguay Starts 27 Mar end 27 mar
<option value=\"8\">Perth </option>
<option value=\"9.5\">Darwin CST </option> //// VIC, SA End 2 April Starts 30 Oct
<option value=\"10\">Sydney EST</option> //// ACT, NSW end 26 Mar Starts 30 Oct
<option value=\"10\">Tasmania </option> //// Tasmania Starts 2 Oct End 26 Mar
<option value=\"11\">Noumea EST</option>
<option value=\"12\">New Zealand</option> //// New Zealand end 19 Mar starts 1 Oct
<option value=\"-10\">Honolulu</option>
<option value=\"-9\">Alaska</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-8\">Vancouver PST</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-7\">Denver MST</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-6\">Nashville CST</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-5\">Montreal EST</option> //// Canada/USA.Mexico Starts 3 Apr end 30 Oct
<option value=\"-4\">Bermuda</option>
<option value=\"-4\">Santiago </option> ////Chile,Paraguay end 13 Mar Starts 18 Sep
<option value=\"-3\">Buenos Aires</option>
<option value=\"-3\">Brasilia </option> //// Brazil end 20 Feb Starts 16 Oct
<option value=\"-2\">Greenland</option>
<option value=\"-1\">Azores</option></select></td>";
$content.="</tr><tr><td width=\"100%\" align=\"center\">";
$content.="<sc ript language=\"JavaS cript\">
if (document.all||document.getElementById)
document.write(' <span id=\"worldclock\" style=\"font:bold 12px Arial;\"></span><br>')
zone=0;
isitlocal=true;
ampm='';
function updateclock(z){
zone=z.options[z.selectedIndex].value;
isitlocal=(z.options[0].selected)?true:false;
}
function WorldClock(){
now=new Date();
ofst=now.getTimezoneOffset()/60;
secs=now.getSeconds();
sec=-1.57+Math.PI*secs/30;
mins=now.getMinutes();
min=-1.57+Math.PI*mins/30;
hr=(isitlocal)?now.getHours():(now.getHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24;
ampm = (hr > 11)?\"PM\":\"AM\";
statusampm = ampm.toLowerCase();
hr2 = hr;
if (hr2 == 0) hr2=12;
(hr2 < 13)?hr2:hr2 %= 12;
if (hr2<10) hr2=\"0\"+hr2
var finaltime=hr2+':'+((mins < 10)?\"0\"+mins:mins)+':'+((secs < 10)?\"0\"+secs:secs)+' '+statusampm;
if (document.all)
worldclock.innerHTML=finaltime
else if (document.getElementById)
document.getElementById(\"worldclock\").innerHTML=finaltime
else if (document.layers){
document.worldclockns.document.worldclockns2.document.write(finaltime)
document.worldclockns.document.worldclockns2.document.close()
}
setTimeout('WorldClock()',1000);
}
window.onload=WorldClock
</ s cript>";
$content.="</tr></table></td></tr></table>";
?>
/*****************************************************************************/
/* block-Clock/Calendar v2.1.1 */
/* para PhpNuke 6.x / 7.x */
/* por Emanuel Pina */
/* emanuel_pina@ptnuke.com */
/* Realizado em: 26-10-2003 */
/*****************************************************************************/
global $prefix, $db;
$result = $db->sql_query("SELECT lang, type, color, width, height, background, dir from ".$prefix."_clockcalendar");
list($lang, $type, $color, $width, $heigth, $background, $dir) = $db->sql_fetchrow($result);
if($type == 0) { $lang = ""; }
else {
if ($lang == "autochange") { $lang = "$language/"; }
else { $lang = "$lang/"; }
}
if ($type == 1) { $type = "clockcalendar"; }
if ($color == 0) { $color = "white"; }
if ($background == "0" OR $background == "") {
$background2 = "transparent";
$background = "#$background";
}
else {
$background2 = "";
$background = "#$background";
}
$flashurl = "$dir$lang$type$color.swf";
$content .= "<TABLE width='100%' height='100' border=0 cellPadding=0 cellSpacing=0>
WIDTH='$width' HEIGHT='$heigth'ALIGN=''>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Steptoe
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Nov 22, 2005 7:14 pm |
|
I have being playing around with this...Im bloody determined to get it working, but just cant get it figured out....
lot of Help please? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|