Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
<SCRIPT LANGUAGE="JavaScript">
2
var timerID ;
3
function tzone(tz, os, ds, cl)
4
{
5
	this.ct = new Date(0) ;		// datetime
6
	this.tz = tz ;		// code
7
	this.os = os ;		// GMT offset
8
	this.ds = ds ;		// has daylight savings
9
	this.cl = cl ;		// font color
10
}
11
 
12
function UpdateClocks()
13
{
14
	var ct = new Array(
15
 
16
		new tzone('PER: ', +8, 0, 'lime'),	
17
		new tzone('SYD: ', +11, 1, 'pink'),
18
		new tzone('SFO: ', -8, 1, 'violet'),
19
		new tzone('SEA: ', -8, 1, 'cyan'),
20
		new tzone('SIN: ', +8, 0, 'yellow'),
21
		new tzone('SLS: ', +1, 1, '#FFAA00'),
22
		new tzone('BEI: ', +8, 0, 'silver'),
23
		new tzone('WDC: ', -5, 1, 'red')
24
	) ;
25
 
26
	var dt = new Date() ;	// [GMT] time according to machine clock
27
 
28
	var startDST = new Date(dt.getFullYear(), 3, 1) ;
29
 
30
	while (startDST.getDay() != 0)
31
 
32
		startDST.setDate(startDST.getDate() + 1) ;
33
 
34
	var endDST = new Date(dt.getFullYear(), 9, 31) ;
35
 
36
	while (endDST.getDay() != 0)
37
 
38
		endDST.setDate(endDST.getDate() - 1) ;
39
 
40
	var ds_active ;		// DS currently active
41
 
42
	if (startDST < dt && dt < endDST)
43
		ds_active = 1 ;
44
	else
45
		ds_active = 0 ;
46
 
47
	// Adjust each clock offset if that clock has DS and in DS.
48
	for(n=0 ; n<ct.length ; n++)
49
		if (ct[n].ds == 1 && ds_active == 1) ct[n].os++ ;
50
	// compensate time zones
51
	gmdt = new Date() ;
52
	for (n=0 ; n<ct.length ; n++)
53
		ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;
54
 
55
	document.all.Clock0.innerHTML =
56
		'<font color="' + ct[0].cl + '">' + ct[0].tz + ClockString(ct[0].ct) + '</font>' ;
57
 
58
	document.all.Clock1.innerHTML =
59
		'<font color="' + ct[1].cl + '">' + ct[1].tz + ClockString(ct[1].ct) + '</font>' ;
60
 
61
	document.all.Clock2.innerHTML =
62
		'<font color="' + ct[2].cl + '">' + ct[2].tz + ClockString(ct[2].ct) + '</font>' ;
63
 
64
	document.all.Clock3.innerHTML =
65
		'<font color="' + ct[3].cl + '">' + ct[3].tz + ClockString(ct[3].ct) + '</font>' ;
66
 
67
	document.all.Clock4.innerHTML =
68
		'<font color="' + ct[4].cl + '">' + ct[4].tz + ClockString(ct[4].ct) + '</font>' ;
69
 
70
	document.all.Clock5.innerHTML =
71
		'<font color="' + ct[5].cl + '">' + ct[5].tz + ClockString(ct[5].ct) + '</font>' ;
72
 
73
	document.all.Clock6.innerHTML =
74
		'<font color="' + ct[6].cl + '">' + ct[6].tz + ClockString(ct[6].ct) + '</font>' ;
75
 
76
	document.all.Clock7.innerHTML =
77
		'<font color="' + ct[7].cl + '">' + ct[7].tz + ClockString(ct[7].ct) + '</font>' ;
78
 
79
	timerID = window.setTimeout("UpdateClocks()", 1001) ;
80
 
81
}
82
 
83
function ClockString(dt)
84
{
85
	var stemp, ampm ;
86
	var dt_year = dt.getUTCFullYear() ;
87
	var dt_month = dt.getUTCMonth() + 1 ;
88
	var dt_day = dt.getUTCDate() ;
89
	var dt_hour = dt.getUTCHours() ;
90
	var dt_minute = dt.getUTCMinutes() ;
91
	var dt_second = dt.getUTCSeconds() ;
92
	dt_year = dt_year.toString() ;
93
	if (0 <= dt_hour && dt_hour < 12)
94
	{
95
		ampm = 'AM' ;
96
		if (dt_hour == 0) dt_hour = 12 ;		
97
	} else {
98
		ampm = 'PM' ;
99
		dt_hour = dt_hour - 12 ;
100
		if (dt_hour == 0) dt_hour = 12 ;		
101
	}
102
	if (dt_minute < 10)
103
		dt_minute = '0' + dt_minute ;
104
	if (dt_second < 10)
105
		dt_second = '0' + dt_second ;
106
 
107
	stemp = dt_day + '/' + dt_month + '/' + dt_year.substr(2,2) ;
108
	stemp = stemp + ' ' + dt_hour + ":" + dt_minute + ":" + dt_second + ' ' + ampm ;
109
 
110
	return stemp ;
111
}
112
</script>
113
 
114
<table border="0" cellspacing="0" width="100%">
115
  <tr bgcolor="#000000" style="font-family: Verdana, Tahoma, Arial; font-size: x-small">
116
    <td ID="Clock0" width="25%" >   </td>
117
    <td ID="Clock1" width="25%" >   </td>
118
    <td ID="Clock2" width="25%" >   </td>
119
    <td ID="Clock3" width="25%" >   </td>
120
  </tr>
121
  <tr bgcolor="#000000" style="font-family: Verdana, Tahoma, Arial; font-size: x-small">
122
    <td ID="Clock4" width="25%" >  </td>
123
    <td ID="Clock5" width="25%" >   </td>
124
    <td ID="Clock6" width="25%" >   </td>
125
    <td ID="Clock7" width="25%" >   </td>
126
  </tr>
127
</table>
128
 
129