/***
!Example Usage
< | Local|<\>|
| Queensland|<\>|
| England (DST)|<\>|
| California (DST)|<\>|
>>
***/
//{{{
version.extensions.ShowClockMacro = { major: 0, minor: 0, revision: 1, date: new Date(2006,7,12),
source: "http://tiddlyspot.com/timezones/#ShowClockMacro"
};
config.macros.showClock = {
defaultClass: 'clock',
// this for seconds
//tickDelay: 1000,
//format: "0DD MMM, YYYY 0hh:0mm:0ss",
// this for minute
tickDelay: 1000 * 15,
format: "0DD MMM, YYYY 0hh:0mm",
styles:
".clock {\n"+
" padding:0 0.5em;\n"+
"}\n" +
".clock .dow { color:#000; }\n" +
".clock .time { color:#000; }\n" +
".clock .offset { color:#999; }\n" +
"",
count: 0,
handler: function (place,macroName,params,wikifier,paramString,tiddler) {
var offset = params[0] || '';
var useClass = params[1] || this.defaultClass;
var c = this.count++;
var clockElement = createTiddlyElement(place, "span", "clock" + c, useClass);
clockElement.setAttribute("offset",offset);
this.refreshDisplay(c);
this.waitForTick(c);
},
waitForTick: function(c) {
setTimeout("config.macros.showClock.tick(" + c + ")", this.tickDelay);
},
tick: function(c) {
if (this.stillHere(c)) {
this.refreshDisplay(c)
this.waitForTick(c);
}
},
getClock: function(c) {
return document.getElementById("clock" + c);
},
stillHere: function(c) {
return this.getClock(c) != null;
},
refreshDisplay: function(c) {
var clock = this.getClock(c);
var offset = clock.getAttribute("offset")
var now = new Date();
//var label = "local";
var label = "";
if (offset && offset != '') {
var offsetInt = parseInt(offset);
now.setHours(now.getHours() + (now.getTimezoneOffset() / 60) + offsetInt);
label = "GMT " + (offsetInt == 0 ? "" : offsetInt > 0 ? "+"+offsetInt : offsetInt);
}
clock.innerHTML =
'' + now.formatString("DDD").substr(0,3) + ' ' +
'' + now.formatString(this.format) + '' +
' ' + label + ''
}
};
setStylesheet(config.macros.showClock.styles,"showClockStyles");
//}}}
!Example Usage
<
| Queensland|<
| England (DST)|<
| California (DST)|<
>>
***/
//{{{
version.extensions.ShowClockMacro = { major: 0, minor: 0, revision: 1, date: new Date(2006,7,12),
source: "http://tiddlyspot.com/timezones/#ShowClockMacro"
};
config.macros.showClock = {
defaultClass: 'clock',
// this for seconds
//tickDelay: 1000,
//format: "0DD MMM, YYYY 0hh:0mm:0ss",
// this for minute
tickDelay: 1000 * 15,
format: "0DD MMM, YYYY 0hh:0mm",
styles:
".clock {\n"+
" padding:0 0.5em;\n"+
"}\n" +
".clock .dow { color:#000; }\n" +
".clock .time { color:#000; }\n" +
".clock .offset { color:#999; }\n" +
"",
count: 0,
handler: function (place,macroName,params,wikifier,paramString,tiddler) {
var offset = params[0] || '';
var useClass = params[1] || this.defaultClass;
var c = this.count++;
var clockElement = createTiddlyElement(place, "span", "clock" + c, useClass);
clockElement.setAttribute("offset",offset);
this.refreshDisplay(c);
this.waitForTick(c);
},
waitForTick: function(c) {
setTimeout("config.macros.showClock.tick(" + c + ")", this.tickDelay);
},
tick: function(c) {
if (this.stillHere(c)) {
this.refreshDisplay(c)
this.waitForTick(c);
}
},
getClock: function(c) {
return document.getElementById("clock" + c);
},
stillHere: function(c) {
return this.getClock(c) != null;
},
refreshDisplay: function(c) {
var clock = this.getClock(c);
var offset = clock.getAttribute("offset")
var now = new Date();
//var label = "local";
var label = "";
if (offset && offset != '') {
var offsetInt = parseInt(offset);
now.setHours(now.getHours() + (now.getTimezoneOffset() / 60) + offsetInt);
label = "GMT " + (offsetInt == 0 ? "" : offsetInt > 0 ? "+"+offsetInt : offsetInt);
}
clock.innerHTML =
'' + now.formatString("DDD").substr(0,3) + ' ' +
'' + now.formatString(this.format) + '' +
' ' + label + ''
}
};
setStylesheet(config.macros.showClock.styles,"showClockStyles");
//}}}