User:Fyrlander/clock.js

/*
 * Add date and time (UTC) to your monobook "personal menu" at the very top of the page
 * User:Mathwiz2020 created the original script Time
 * copied 12 June 2007 from WikiProject User scripts/Scripts/Time
 * User:Fyrlander removed display of seconds and year, swapped date and time, and removed text "(utc)" (for readability)



// Indicate where you would like the time to appear: // 1 is to the right of username, ..., 5 is to the right of my contributions link, 6 is to the right of log out link // (0 for the left side of username doesn't work ...) insertBeforeNum = 5;

// Do NOT edit below this line unless you're experiened in javascript insertBeforeArr = new Array("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout",""); insertBefore = insertBeforeArr[insertBeforeNum];

function makeTime { var li = document.createElement( 'li' ); li.id = 'pt-time';

var mySpan = document.createElement( 'span' ); mySpan.appendChild( document.createTextNode( 'date and time' ) );

li.appendChild( mySpan );

if ( insertBefore ) {   var before = document.getElementById( insertBefore ); before.appendChild( li, before ); } else // append to end (right) of list {   document.getElementById( 'pt-logout' ).parentNode.appendChild( li ); }

getTime; }

if     ( window.addEventListener ) window.addEventListener ( 'load', makeTime, false ); else if ( window.attachEvent     ) window.attachEvent      ( 'onload', makeTime      );

function getTime {   var time    = new Date; var date   = time.getUTCDate; var months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '); month  = months[time.getUTCMonth]; var hours  = '0' + time.getUTCHours; hours  = hours.substr(hours.length-2, hours.length); var minutes = '0' + time.getUTCMinutes; minutes = minutes.substr(minutes.length-2, minutes.length); var curTime = " " + date + " " + month + ", " + hours + ":" + minutes + " "; datePlace  = document.getElementById('pt-time').childNodes[0].childNodes[0]; datePlace.replaceData(0, datePlace.length, curTime); doTime     = window.setTimeout("getTime", 1000); } //