Inde på netcoder.dk har (en anden)Søren lagt ind et script
soren@grenz.dk
Det ser sådan ud :
<%
REM Funktionen worldtimes start
Function worldtimes(gmt)
Dim storbyminus, storbyplus, a
storbyplus = Array(\"London\", \"Paris\", \"Cairo\", \"Moskva\", \"Baku\", \"Karachi\", \"Dacca\", \"Bangkok\", \"Hong Kong\", \"Tokyo\", \"Sydney\", \"Moumea\", \"Wellington\")
storbyminus = Array(\"Samao\", \"Hawaii\", \"Juneau\", \"San Francisco\", \"Denver\", \"Chicago\", \"New York\", \"Caracas\", \"Rio De Janeiro\", \"Recife\", \"Azores\")
For a = -11 to 12
If a < 0 then Response.Write \"<TR><TD>\"& Dateadd(\"h\",a-gmt,Now) &\"</TD><TD>\"& storbyminus(a+11) &\"</TD><TD ALIGN=\"\"RIGHT\"\">\"& a &\"</TD></TR>\"& VbCrLf
IF a >= 0 Then Response.Write \"<TR><TD>\"& Dateadd(\"h\",a-gmt,Now) &\"</TD><TD>\"& storbyplus(a) &\"</TD><TD ALIGN=\"\"RIGHT\"\">\"& a &\"</TD></TR>\"& VbCrLf
Next
End Function
REM Funktionen worldtimes slut
%>
Hmmm, lidt for simpelt, men ideen er god nok.
Der er ikke andet for end at jeg må kode skidtet selv.
Er der ikke nogen der kan komme med en \"smartere\" rutine inden for de næste par dage skal du nok få point ;-)
/Søren
Kig en tur forbi dette link:
http://sandbox.xerox.com/ (...)- det skulle vist være koden til den converter du selv nævner.
Mere info på:
http://sandbox.xerox.com/ (...)
Tak senj, men scriptet dine URL\'s pejer på er mere eller mindre magen til den jeg postede i mit spørgsmål ;-)
Desuden er de i Perl, bvadr, hehe...
Ja, simpelt! For Søren! Det mangler lige et \'s\'
netcoders.dk :)
Nå, så Perl bliver for langhåret for dig :-)
<HTML>
<!--This file created 9/25/00 4:42 PM by Claris Home Page version 3.0-->
<HEAD>
<TITLE>JavaScript World Clock</TITLE>
<META NAME=GENERATOR CONTENT=\"Claris Home Page 3.0\">
<X-CLARIS-WINDOW TOP=38 BOTTOM=452 LEFT=93 RIGHT=623>
<X-CLARIS-TAGVIEW MODE=minimal>
</HEAD>
<BODY TEXT=\"#FFFF80\" BGCOLOR=\"#004040\" LINK=\"#0080FF\" VLINK=\"#8080FF\">
<CENTER><FONT SIZE=\"+3\" COLOR=\"#FF8040\"><B>JavaScript World Clock v
2.0</B></FONT><BR>
</CENTER>
<P>
<HR>
<FORM ACTION=\"\" METHOD=POST name=\"set_tz\">
<CENTER>Current Time
Zone: <INPUT TYPE=text NAME=current VALUE=\"Automatic\" SIZE=30 MAXLENGTH=80>
<SELECT NAME=zone onchange=\"new_tz();\">
<OPTION>You may manually select your time zone here
<OPTION>GMT-11
<OPTION>GMT-10
<OPTION>GMT-09
<OPTION>GMT-08 (PST)
<OPTION>GMT-07 (MST)
<OPTION>GMT-06 (CST)
<OPTION>GMT-05 (EST)
<OPTION>GMT-04
<OPTION>GMT-03
<OPTION>GMT-02
<OPTION>GMT-01
<OPTION>GMT+00 (GMT)
<OPTION>GMT+01
<OPTION>GMT+02
<OPTION>GMT+03
<OPTION>GMT+04
<OPTION>GMT+05
<OPTION>GMT+06
<OPTION>GMT+07
<OPTION>GMT+08
<OPTION>GMT+09
<OPTION>GMT+10
<OPTION>GMT+11
<OPTION>GMT+12
<OPTION>Automatic
</SELECT></CENTER>
</FORM></P>
<CENTER><BR>
<BR>
<P><FORM ACTION=\"\" METHOD=POST name=clock>
<P><DIV ALIGN=\"center\"></P>
<CENTER><TABLE BORDER=1 BGCOLOR=\"#000040\" WIDTH=\"95%\" align=Center>
<TR>
<TD ALIGN=center COLSPAN=2>
<P><FONT COLOR=\"#FF8040\"><INPUT TYPE=radio NAME=ampm VALUE=y CHECKED onclick=\"disp_ampm = 1;\">AM/PM
<INPUT TYPE=radio NAME=ampm VALUE=n onclick=\"disp_ampm = 0;\">24
Hr.</FONT></P>
</TD>
<TD ALIGN=center COLSPAN=2>
<P><FONT COLOR=\"#FF8040\"><INPUT TYPE=radio NAME=dst VALUE=y onclick=\"disp_dst = 1;\">Daylight
Time
<INPUT TYPE=radio NAME=dst VALUE=n CHECKED onclick=\"disp_dst = 0;\">Standard
Time</FONT></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -11</P>
</TD>
<TD ALIGN=center>
<P>Lng. 165 W</P>
</TD>
<TD>
<P>Samoa</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-11\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -10</P>
</TD>
<TD ALIGN=center>
<P>Lng. 150 W</P>
</TD>
<TD>
<P>Hawaii</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-10\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -09</P>
</TD>
<TD ALIGN=center>
<P>Lng. 135 W</P>
</TD>
<TD>
<P>Alaska</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-09\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -08</P>
</TD>
<TD ALIGN=center>
<P>Lng. 120 W</P>
</TD>
<TD>
<P>California<BR>
Los Angeles</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-08\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -07</P>
</TD>
<TD ALIGN=center>
<P>Lng. 105 W</P>
</TD>
<TD>
<P>Mexico<BR>
Colorado<BR>
Brzzil<BR>
CSU</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-07\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -06</P>
</TD>
<TD ALIGN=center>
<P>Lng. 090 W</P>
</TD>
<TD>
<P>Mississippi<BR>
Gulf of Mexico</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-06\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR BGCOLOR=\"#00FFFF\">
<TD ALIGN=center>
<P><FONT COLOR=\"#000000\">GMT -05</FONT></P>
</TD>
<TD ALIGN=center>
<P><FONT COLOR=\"#000000\">Lng. 075 W</FONT></P>
</TD>
<TD>
<P><FONT COLOR=\"#000000\"><B>Our TimeZone</B><BR>
Boston<BR>
Brazil<BR>
Maine<BR>
Montreal<BR>
Quebec<BR>
Bahamas</FONT></P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-05\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -04</P>
</TD>
<TD ALIGN=center>
<P>Lng. 060 W</P>
</TD>
<TD>
<P>Brazil</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-04\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -03</P>
</TD>
<TD ALIGN=center>
<P>Lng. 045 W</P>
</TD>
<TD>
<P>Rio De Janeiro<BR>
Brazil</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-03\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -02</P>
</TD>
<TD ALIGN=center>
<P>Lng. 030 W</P>
</TD>
<TD>
<P>Reykjavik</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-02\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT -01</P>
</TD>
<TD ALIGN=center>
<P>Lng. 015 W</P>
</TD>
<TD>
<P>Azores</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT-01\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +00</P>
</TD>
<TD ALIGN=center>
<P>Lng. 000 W</P>
</TD>
<TD>
<P>GMT London</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+00\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +01</P>
</TD>
<TD ALIGN=center>
<P>Lng. 015 E</P>
</TD>
<TD>
<P>Paris</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+01\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +02</P>
</TD>
<TD ALIGN=center>
<P>Lng. 030 E</P>
</TD>
<TD>
<P>South Africa</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+02\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +03</P>
</TD>
<TD ALIGN=center>
<P>Lng. 045 E</P>
</TD>
<TD>
<P>Moscow<BR>
Ethopia<BR>
Jerusalem<BR>
Beirut</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+03\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +04</P>
</TD>
<TD ALIGN=center>
<P>Lng. 060 E</P>
</TD>
<TD>
<P>Baku</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+04\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +05</P>
</TD>
<TD ALIGN=center>
<P>Lng. 075 E</P>
</TD>
<TD>
<P>Karachi</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+05\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +06</P>
</TD>
<TD ALIGN=center>
<P>Lng. 090 E</P>
</TD>
<TD>
<P>Bay of Bengal</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+06\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +07</P>
</TD>
<TD ALIGN=center>
<P>Lng. 105 E</P>
</TD>
<TD>
<P>Sumatra<BR>
Southern Thailand<BR>
Malaysia<BR>
Kuala Lampur<BR>
Medan<BR>
Singapore</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+07\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +08</P>
</TD>
<TD ALIGN=center>
<P>Lng. 120 E</P>
</TD>
<TD>
<P>Borneo<BR>
Malasia<BR>
Jakarta<BR>
Philippines<BR>
Vietnam<BR>
Hanoi</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+08\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +09</P>
</TD>
<TD ALIGN=center>
<P>Lng. 135 E</P>
</TD>
<TD>
<P>Tokyo<BR>
Indonedia<BR>
Papua<BR>
New Guinea<BR>
Australia<BR>
Japan</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+09\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +10</P>
</TD>
<TD ALIGN=center>
<P>Lng. 150 E</P>
</TD>
<TD>
<P>Sydney</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+10\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +11</P>
</TD>
<TD ALIGN=center>
<P>Lng. 165 E</P>
</TD>
<TD>
<P>Noumea</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+11\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
<TR>
<TD ALIGN=center>
<P>GMT +12</P>
</TD>
<TD ALIGN=center>
<P>Lng. 180 E</P>
</TD>
<TD>
<P>Marshall Island<BR>
Aleutian Islands</P>
</TD>
<TD ALIGN=center>
<P><INPUT TYPE=text NAME=\"GMT+12\" VALUE=\"\" SIZE=35 MAXLENGTH=256></P>
</TD>
</TR>
</TABLE>
</CENTER>
<P></DIV>
</FORM> <DIV ALIGN=\"center\"> <A HREF=\"elninodefault.htm\">Back to El
Nino Home</A></P>
<P><A NAME=footnote></A><TABLE CELLPADDING=10 WIDTH=\"95%\" align=Center>
<TR>
<TD>
<P><FONT SIZE=\"+1\" COLOR=\"#FF8040\"><B><I>The Time Zone
Problem</I></B></FONT></P>
<CENTER><I>Current versions of JavaScript do not report the
correct time zone, for one of several reasons.</I></CENTER>
<P>First, if Daylight Time is in effect on the system, this
causes a one hour error in the reported time zone.</P>
<P>Second, MSIE 3.0, Netscape 3.0 Beta, and Netscape 2.0 do
three different things with this quantity (and there are
probably other differences in browsers I haven\'t tested).
Netscape 2.0 always reports an incorrect value. Netscape
browsers return a non-integer value for the number of
minutes between GMT and the local zone -- this is obviously
impossible.</P>
<P>The final release of Netscape Navigator (3.0p) reverses
the sign of the time zone, so people who live in the Western
Hemisphere appear to be living in the Eastern Hemisphere and
vice versa! I long for the good old days when computer
programmers <I>wrote</I> and then <I>released</I> their
programs, instead of the other way around.</P>
<P>All I can say is, World Clock tries to get the correct
time zone value, but it will not be correct on some
browsers. You may have to manually select your time zone.
Sorry!</P>
<P><B>NEW:</B> JavaScript World Clock v 2.0 attempts to
detect the browser and automatically work around the
Netscape reverse-time bug, which has been blindly carried
over into the new Netscape 4.0.</P>
</TD>
</TR>
</TABLE>
</P></CENTER>
<P></DIV> <SCRIPT LANGUAGE=JavaScript><!--- hide this
// copyright (c) 1996, P. Lutus lutusp@arachnoid.com
// Windows 95 will not report the correct time zone while daylight time is in effect,
// Netscape 3.0 doesn\'t return a multiple of minutes * 60,
// Netscape 2.0 will not report it correctly at all.
var disp_ampm = 1;
var disp_dst = 0;
var start = 1;
// this next line works around a long-standing Netscape bug
// all Netscape browsers after version 2
var reverse_tz = ((navigator.appName == \"Netscape\") && (navigator.appVersion.substring(0,1) != \"2\"));
function get_tz(x) {
var tzoff,now;
now = new Date();
tzoff = now.getTimezoneOffset()/60; // get hour offset
if(reverse_tz) {
tzoff = -tzoff; // isn\'t this inelegant?
}
sgn = (tzoff < 0); // get sign
tzoff = Math.abs(tzoff); // take absolute value
tzoff = Math.ceil(tzoff); // get nearest whole hour (corrects a Netscape 3.0 bug)
tzoff = (sgn)?-tzoff:tzoff; // restore sign
return(tzoff);
}
function auto_tz() {
var tzoff = get_tz();
var sgn = (tzoff < 0)?\"-\":\"+\";
var q = Math.abs(tzoff);
idl = (tzoff * 3600000.0) + 39600000.0; // get offset to GMT -11 in milliseconds, the first time zone
document.set_tz.current.value = document.set_tz.zone.options[tzoff+12].text + \" (automatic)\";
return tzoff;
}
function new_tz() {
tzoff = document.set_tz.zone.options.selectedIndex - 12;
if((tzoff >= -11) && (tzoff <= 12)) {
idl = (tzoff * 3600000.0) + 39600000.0; // get offset to GMT -11 in milliseconds, the first time zone
document.set_tz.current.value = document.set_tz.zone.options[tzoff+12].text + \" (manual)\";
}
else {
if((tzoff == 13) || (tzoff == -12)) {
tzoff = auto_tz();
document.set_tz.current.value = document.set_tz.zone.options[tzoff+12].text + \" (automatic)\";
}
}
}
auto_tz(); // set initial value
daynames = \"SunMonTueWedThuFriSat\";
function set_dst(x) {
month = x.getMonth()+1; // Jan = 0, so add 1
if ((month >= 4) && (month <= 10)) { // set default Daylight Savings Time for these months
disp_dst = 1;
}
document.clock.elements[3-disp_dst].checked = 1; // click either standard or daylight time
}
function ldg_zero(x) {
if (x < 10) {
x = \"0\" + x;
}
return(x);
}
function format_date(x) {
month = x.getMonth()+1; // Jan = 0, so add 1
dom = x.getDate(); // day of month
dow = x.getDay(); // day of week
year = x.getYear();
hour = x.getHours();
year = (year > 50)?1900+year:2000+year;
ampm = \"\";
if(disp_ampm) {
ampm = (hour > 11)?\"PM\":\"AM\";
hour %= 12;
hour = (hour < 1)?hour+12:hour;
}
hour = ldg_zero(hour);
minute = ldg_zero(x.getMinutes());
second = ldg_zero(x.getSeconds());
dow3 = dow * 3;
dt = \"\";
if (disp_dst) {
dt = \"(DT)\";
}
return(daynames.substring(dow3,dow3+3)+\" \"+month+\"/\"+dom+\"/\"+year+\" \"+hour+\":\"+minute+\":\"+second+\" \"+ampm+\" \"+dt);
}
function update_clock() {
now = new Date();
if(start) {
set_dst(now);
start = 0;
}
q = idl; // set var q to previously calculated first time zone offset
if(disp_dst) {
q -= 3600000.0; // add 1 hour for DST
}
now.setTime(now.getTime() - q); // set clock to GMT -11
for(i = 0;i < 24;i++) { // cycle through 24 time zones
document.clock.elements[i+4].value = format_date(now); // skip the 4 radio buttons in the form
now.setTime(now.getTime() + 3600000.0);
}
setTimeout(\'update_clock()\', 999);
}
update_clock(); // first time
// end hide --></SCRIPT></P>
</BODY>
</HTML>
Ganske enkelt genialt, senj!
Jeg siger mange, mange tak ;-)
Mvh.
Søren S.
Det var så lidt!
mvh
Søren J (for det ikke skal være løgn)