Help talk:UTC clock
From Homestar Runner Wiki
Suuuuuuure, now I find this page! Anyway, when I hacked Mathwiz2020's code to get it to work here, I figured out that the reason it doesn't work elsewhere isn't necessarily because the Monobook skin is different, but because Wikimedia's Wikibits file is is insanely huge and has way more hooks than ours (if we even have one I assume it's still set at the MediaWiki default) does. The code in its present form has some weird parameter that sets every possible modifications of the gsTimeInsertBefore variable to a numeric value so there's less chance of error when you sset where you want it to go. I can't for the life of me figure out how that's working, as it doesn't look logical, but the old version that both Joey and I modified to work herereally just needs the following to be put at the beginning of your monobook.js for you to be able to use it without any modifications:
var doneOnloadHook; if (!window.onloadFuncts) var onloadFuncts = []; function addOnloadHook(hookFunct) { // Allows add-on scripts to add onload functions onloadFuncts[onloadFuncts.length] = hookFunct; } function runOnloadHook() { // don't run anything below this for non-dom browsers if (doneOnloadHook || !(document.getElementById && document.getElementsByTagName)) return; histrowinit(); unhidetzbutton(); tabbedprefs(); akeytt(); scrollEditBox(); setupCheckboxShiftClick(); // Run any added-on functions for (var i = 0; i < onloadFuncts.length; i++) onloadFuncts[i](); doneOnloadHook = true; } function hookEvent(hookName, hookFunct) { if (window.addEventListener) addEventListener(hookName, hookFunct, false); else if (window.attachEvent) attachEvent("on" + hookName, hookFunct); } hookEvent("load", runOnloadHook);
— User:ACupOfCoffee@ 16:25, 28 April 2006 (UTC)
Is there a way to modify this script for specific timezones? -- Super Martyo boing! 22:21, 20 September 2007 (UTC)
- To offset it for time zones (not the one above, the one on the article), just change the "hours + ":" + minutes" into "hours (+ or - and how many hours) + ":" + minutes. So, if you want to make it 6 hours less, copy and paste this in your monobook.js:
// Add UTC time just below the "personal menu" list at the top of the page. // Created by Wikipedia:User:Mathwiz2020, modified by User:JoeyDay // function getTime() { var time = new Date(); var hours = time.getUTCHours(); if (hours < 10) { hours = "0" + hours; } var minutes = time.getUTCMinutes(); if (minutes < 10) { minutes = "0" + minutes; } var currentTime = hours -6 + ":" + minutes document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 5, currentTime); doTime = window.setTimeout("getTime()", 1000); } function makeTime() { var div = document.createElement( 'div' ); div.id = 'pt-time'; var mySpan = document.createElement( 'span' ); mySpan.appendChild( document.createTextNode( '00:00 UTC' ) ); div.appendChild( mySpan ); document.getElementById( 'globalWrapper' ).parentNode.appendChild( div ); doTime = window.setTimeout("getTime()", 1000); } if (window.addEventListener) window.addEventListener ('load', makeTime, false); else if (window.attachEvent) window.attachEvent ('onload', makeTime);
Get it? SuperfieldCreditUnion