You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
2.9 KiB
JavaScript

<!-- Begin
var timerID ;
function tzone(os, ds, cl)
{
this.ct = new Date(0) ; // datetime
this.os = os ; // GMT offset
this.ds = ds ; // has daylight savings
this.cl = cl ; // font color
}
function UpdateClocks(e)
{
var ct = new Array(
new tzone(8, 1, 'silver')
) ;
var dt = new Date() ; // [GMT] time according to machine clock
var startDST = new Date(dt.getFullYear(), 3, 1) ;
while (startDST.getDay() != 0)
startDST.setDate(startDST.getDate() + 1) ;
var endDST = new Date(dt.getFullYear(), 9, 31) ;
while (endDST.getDay() != 0)
endDST.setDate(endDST.getDate() - 1) ;
var ds_active ; // DS currently active
if (startDST < dt && dt < endDST)
ds_active = 1 ;
else
ds_active = 0 ;
// Adjust each clock offset if that clock has DS and in DS.
// for(n=0 ; n<ct.length ; n++)
// if (ct[n].ds == 1 && ds_active == 1) ct[n].os++ ;
// compensate time zones
var printstr = "";
gmdt = new Date() ;
//alert(gmdt);
//alert(gmdt.getTime());
//alert(ct[0].os);
//alert(gmdt.getTime() + ct[0].os * 3600 * 1000);
for (n=0 ; n<ct.length ; n++) {
//alert(gmdt.getTime());
//alert(ct[n].os);
ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;
//alert(ct[0].ct);
}
var obj=document.getElementById(e);
//alert(ct[0].ct);
obj.innerHTML = ClockString(ct[0].ct);
}
function ClockString(dt)
{
var stemp ;
var dt_year = dt.getUTCFullYear() ;
var dt_month = dt.getUTCMonth() + 1 ;
var dt_day = dt.getUTCDate();
var dt_hour = dt.getUTCHours() ;
var dt_minute = dt.getUTCMinutes() ;
var dt_second = dt.getUTCSeconds() ;
dt_year = dt_year.toString() ;
var temptime
//alert(dt_year+"/"+dt_month+"/"+dt_day+" "+dt_hour+":"+dt_minute);
if (dt_hour>12){
dt_hour=dt_hour-12;
temptime=getClockTwoString(dt_hour)+":"+getClockTwoString(dt_minute)+"pm";
//alert("A");
}
else if (dt_hour==12){
temptime=getClockTwoString(dt_hour)+":"+getClockTwoString(dt_minute);
//alert("B");
}
else{
temptime=getClockTwoString(dt_hour)+":"+(dt_minute)+"am";
//alert("C");
}
//alert(temptime);
stemp = GetClockMonth(dt_month) + ' ' + getClockTwoString(dt_day) + ', '+dt_year;
stemp = temptime + ' ' +stemp;
return stemp ;
}
function getClockTwoString(num){
if (num < 10){
return '0' + num;
}
else{
return num;
}
}
function GetClockMonth(themonth){
var month_eng
switch (themonth){
case 1:
month_eng="Jan";
break;
case 2:
month_eng="Feb";
break;
case 3:
month_eng="Mar";
break;
case 4:
month_eng="Apr";
break;
case 5:
month_eng="May";
break;
case 6:
month_eng="Jun";
break;
case 7:
month_eng="Jul";
break;
case 8:
month_eng="Aug";
break;
case 9:
month_eng="Sep";
break;
case 10:
month_eng="Oct";
break;
case 11:
month_eng="Nov";
break;
case 12:
month_eng="Dec";
break;
}
return month_eng
}
// End -->