Work in progress — This wiki is an active migration / mirror of Homestar Runner Wiki and is not finished yet. Account registration and public editing are turned off until the migration is further along. For status updates, see the migration thread on the forums.

Help UTC clock: Difference between revisions

From HR Wiki Twice
Jump to navigationJump to search
imported>HRWikiMirrorBot
Imported from hrwiki.org via Wayback Machine (HTML→wikitext)
 
imported>HRWikiMirrorBot
Reimported from hrwiki.org Wayback HTML→wikitext (full reconvert)
 
Line 1: Line 1:
<!-- Mirrored from Homestar Runner Wiki (hrwiki.org) via Wayback Machine; HTML converted to wikitext. Formatting may be imperfect. -->
<!-- Mirrored from Homestar Runner Wiki (hrwiki.org) via Wayback Machine -->
The following JavaScript and CSS code will add a UTC clock to every wiki page. This can be useful for comparing comment timestamps to the current time. The code was originally taken from [[Wikipedia:WikiProject User scripts/Scripts/Time]], but it has been modified slightly for use on our modified version of the MonoBook skin.
The following JavaScript and CSS code will add a UTC clock to every wiki page. This can be useful for comparing comment timestamps to the current time. The code was originally taken from [[Wikipedia:WikiProject User scripts/Scripts/Time]], but it has been modified slightly for use on our modified version of the MonoBook skin.


Note that this clock tells time relative to your computer's local time. It doesn't get its time from the wiki server. If the time or the time zone is set incorrectly on your computer, the adjustment for UTC may be calculated incorrectly.
Note that this clock tells time relative to your computer's local time. It doesn't get its time from the wiki server. If the time or the time zone is set incorrectly on your computer, the adjustment for UTC may be calculated incorrectly.


{| id="toc" class="wikitable toc" summary="Contents"
== Just below the personal menu ==
|-
| <div id="toctitle">


<span id="contents"></span>
https://web.archive.org/web/20211001000000im_/http://www.hrwiki.org/w/images/8/84/UTC-clock-script-below-bar.png
== Contents ==


</div>
''Example 1''
* [#Just_below_the_personal_menu 1 Just below the personal menu]
** [#Javascript 1.1 Javascript]
*** [#Clock_with_Seconds_counter 1.1.1 Clock with Seconds counter]
** [#CSS 1.2 CSS]
* [#On_the_personal_menu 2 On the personal menu]
** [#Javascript_2 2.1 Javascript]
** [#CSS_2 2.2 CSS]


|}
<span id="just-below-the-personal-menu"></span>
== <span class="mw-headline"> Just below the personal menu </span> ==
<div class="thumb tright">
<div class="thumbinner" style="width:307px;">
[[File:UTC-clock-script-below-bar.png|[[File:UTC-clock-script-below-bar.png|305px|thumb]]]]
<div class="thumbcaption">
<div class="magnify">
[[File:UTC-clock-script-below-bar.png|[[File:magnify-clip.png|15px|thumb]]]]
</div>
Example 1
</div>
</div>
</div>
Use this version of the script to place the time just below your personal menu to the far right of the page action tabs.
Use this version of the script to place the time just below your personal menu to the far right of the page action tabs.


<span id="javascript"></span>
=== Javascript ===
=== <span class="mw-headline"> Javascript </span> ===


Put this in [/wiki/Special:MyPage/monobook.js your monobook.js file].
Put this in [/wiki/Special:MyPage/monobook.js your monobook.js file].


<pre>// Add UTC time just below the &quot;personal menu&quot; list at the top of the page.
<pre>// Add UTC time just below the "personal menu" list at the top of the page.
// Created by [[User:Mathwiz2020|Wikipedia:User:Mathwiz2020]], modified by [[User:JoeyDay]]
// Created by Wikipedia:User:Mathwiz2020, modified by User:JoeyDay
//
//
function getTime() {
function getTime() {
   var time = new Date();
   var time = new Date();
   var hours = time.getUTCHours();
   var hours = time.getUTCHours();
   if (hours &lt; 10) { hours = &quot;0&quot; + hours; }
   if (hours < 10) { hours = "0" + hours; }
   var minutes = time.getUTCMinutes();
   var minutes = time.getUTCMinutes();
   if (minutes &lt; 10) { minutes = &quot;0&quot; + minutes; }
   if (minutes < 10) { minutes = "0" + minutes; }
   var currentTime = hours + &quot;:&quot; + minutes
   var currentTime = hours + ":" + minutes
   document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 5, currentTime);
   document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 5, currentTime);
   doTime = window.setTimeout(&quot;getTime()&quot;, 1000);
   doTime = window.setTimeout("getTime()", 1000);
}
}
function makeTime() {
function makeTime() {
Line 71: Line 36:
   div.appendChild( mySpan );
   div.appendChild( mySpan );
   document.getElementById( 'globalWrapper' ).parentNode.appendChild( div );
   document.getElementById( 'globalWrapper' ).parentNode.appendChild( div );
   doTime = window.setTimeout(&quot;getTime()&quot;, 1000);
   doTime = window.setTimeout("getTime()", 1000);
}
}
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
else if (window.attachEvent) window.attachEvent ('onload', makeTime);</pre>
else if (window.attachEvent) window.attachEvent ('onload', makeTime);
<span id="clock-with-seconds-counter"></span>
</pre>
==== <span class="mw-headline"> Clock with Seconds counter </span> ====
 
==== Clock with Seconds counter ====


For the clock with the seconds counter, use this instead:
For the clock with the seconds counter, use this instead:


<pre>function getTime() {
<pre>
function getTime() {
   var time = new Date();
   var time = new Date();
   var hours = time.getUTCHours();
   var hours = time.getUTCHours();
   if (hours &lt; 10) { hours = &quot;0&quot; + hours; }
   if (hours < 10) { hours = "0" + hours; }
   var minutes = time.getUTCMinutes();
   var minutes = time.getUTCMinutes();
   if (minutes &lt; 10) { minutes = &quot;0&quot; + minutes; }
   if (minutes < 10) { minutes = "0" + minutes; }
   var seconds = time.getUTCSeconds();
   var seconds = time.getUTCSeconds();
   if (seconds &lt; 10) { seconds = &quot;0&quot; + seconds; }
   if (seconds < 10) { seconds = "0" + seconds; }
   var currentTime = hours + &quot;:&quot; + minutes + &quot;:&quot; + seconds;
   var currentTime = hours + ":" + minutes + ":" + seconds;
   document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 8, currentTime);
   document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 8, currentTime);
   doTime = window.setTimeout(&quot;getTime()&quot;, 1000);
   doTime = window.setTimeout("getTime()", 1000);
}
}
function makeTime() {
function makeTime() {
Line 99: Line 66:
   div.appendChild( mySpan );
   div.appendChild( mySpan );
   document.getElementById( 'globalWrapper' ).parentNode.appendChild( div );
   document.getElementById( 'globalWrapper' ).parentNode.appendChild( div );
   doTime = window.setTimeout(&quot;getTime()&quot;, 1000);
   doTime = window.setTimeout("getTime()", 1000);
}
}
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
else if (window.attachEvent) window.attachEvent ('onload', makeTime);</pre>
else if (window.attachEvent) window.attachEvent ('onload', makeTime);</pre>
<span id="css"></span>
 
=== <span class="mw-headline"> CSS </span> ===
=== CSS ===


Put this in [/wiki/Special:MyPage/monobook.css your monobook.css page].
Put this in [/wiki/Special:MyPage/monobook.css your monobook.css page].
Line 115: Line 82:
   top: 1.9em;
   top: 1.9em;
   right: 2.2em;
   right: 2.2em;
}</pre>
}
<span id="on-the-personal-menu"></span>
</pre>
== <span class="mw-headline"> On the personal menu </span> ==
 
<div class="thumb tright">
 
<div class="thumbinner" style="width:307px;">


[[File:UTC-clock-script-on-bar.png|[[File:UTC-clock-script-on-bar.png|305px|thumb]]]]
== On the personal menu ==
<div class="thumbcaption">


<div class="magnify">
https://web.archive.org/web/20211001000000im_/http://www.hrwiki.org/w/images/6/6d/UTC-clock-script-on-bar.png


[[File:UTC-clock-script-on-bar.png|[[File:magnify-clip.png|15px|thumb]]]]
''Example 2''


</div>
Use this version of the script to place the time on your personal menu. By default, the clock will appear to the right of your "log out" link. You can customize it by changing the value of the gsTimeInsertBefore variable. For example, to place the clock to the left of your username, set gsTimeInsertBefore to 'pt-userpage'.
Example 2


</div>
=== Javascript ===
 
</div>
 
</div>
Use this version of the script to place the time on your personal menu. By default, the clock will appear to the right of your &quot;log out&quot; link. You can customize it by changing the value of the gsTimeInsertBefore variable. For example, to place the clock to the left of your username, set gsTimeInsertBefore to 'pt-userpage'.
 
<span id="javascript-1"></span>
=== <span class="mw-headline"> Javascript </span> ===


Put this in [/wiki/Special:MyPage/monobook.js your monobook.js file].
Put this in [/wiki/Special:MyPage/monobook.js your monobook.js file].


<pre>// Add time to the &quot;personal menu&quot; at the top of the page.
<pre>// Add time to the "personal menu" at the top of the page.
// Created by [[User:Mathwiz2020|Wikipedia:User:Mathwiz2020]], modified by [[User:JoeyDay]]
// Created by Wikipedia:User:Mathwiz2020, modified by User:JoeyDay
//
//
// Indicate where you would like the time to appear:
// Indicate where you would like the time to appear:
Line 152: Line 104:
//  pt-watchlist, pt-mycontris, pt-logout
//  pt-watchlist, pt-mycontris, pt-logout
//
//
gsTimeInsertBefore = ; // leave blank to append after &quot;logout&quot;
gsTimeInsertBefore = ; // leave blank to append after "logout"
//
//
function getTime() {
function getTime() {
   var time = new Date();
   var time = new Date();
   var hours = time.getUTCHours();
   var hours = time.getUTCHours();
   if (hours &lt; 10) { hours = &quot;0&quot; + hours; }
   if (hours < 10) { hours = "0" + hours; }
   var minutes = time.getUTCMinutes();
   var minutes = time.getUTCMinutes();
   if (minutes &lt; 10) { minutes = &quot;0&quot; + minutes; }
   if (minutes < 10) { minutes = "0" + minutes; }
   var currentTime = hours + &quot;:&quot; + minutes
   var currentTime = hours + ":" + minutes
   document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 5, currentTime);
   document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 5, currentTime);
   doTime = window.setTimeout(&quot;getTime()&quot;, 1000);
   doTime = window.setTimeout("getTime()", 1000);
}
}
function makeTime() {
function makeTime() {
Line 177: Line 129:
     document.getElementById('pt-logout').parentNode.appendChild(li);
     document.getElementById('pt-logout').parentNode.appendChild(li);
   }
   }
   doTime = window.setTimeout(&quot;getTime()&quot;, 1000);
   doTime = window.setTimeout("getTime()", 1000);
}
}
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
else if (window.attachEvent) window.attachEvent ('onload', makeTime);</pre>
else if (window.attachEvent) window.attachEvent ('onload', makeTime);
<span id="css-1"></span>
</pre>
=== <span class="mw-headline"> CSS </span> ===
 
=== CSS ===


Put this in [/wiki/Special:MyPage/monobook.css your monobook.css file].
Put this in [/wiki/Special:MyPage/monobook.css your monobook.css file].
Line 190: Line 143:
   font-size: 11px;
   font-size: 11px;
   text-transform: lowercase;
   text-transform: lowercase;
}</pre>
}
<div id="catlinks" class="catlinks">
</pre>
 
[[Category:Help]]
<div id="mw-normal-catlinks">
 
[/wiki/Special:Categories Category]: <span dir="ltr">[[Category:Help|Help]]</span>
 
</div>
 
</div>



Latest revision as of 14:24, 14 July 2026

The following JavaScript and CSS code will add a UTC clock to every wiki page. This can be useful for comparing comment timestamps to the current time. The code was originally taken from Wikipedia:WikiProject User scripts/Scripts/Time, but it has been modified slightly for use on our modified version of the MonoBook skin.

Note that this clock tells time relative to your computer's local time. It doesn't get its time from the wiki server. If the time or the time zone is set incorrectly on your computer, the adjustment for UTC may be calculated incorrectly.

Just below the personal menu

UTC-clock-script-below-bar.png

Example 1

Use this version of the script to place the time just below your personal menu to the far right of the page action tabs.

Javascript

Put this in [/wiki/Special:MyPage/monobook.js your monobook.js file].

// 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 + ":" + 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);

Clock with Seconds counter

For the clock with the seconds counter, use this instead:

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 seconds = time.getUTCSeconds();
  if (seconds < 10) { seconds = "0" + seconds; }
  var currentTime = hours + ":" + minutes + ":" + seconds;
  document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 8, 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: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);

CSS

Put this in [/wiki/Special:MyPage/monobook.css your monobook.css page].

#pt-time span {
   color: #666;
   font-size: 11px;
   text-transform: lowercase;
   position: absolute;
   top: 1.9em;
   right: 2.2em;
}

On the personal menu

UTC-clock-script-on-bar.png

Example 2

Use this version of the script to place the time on your personal menu. By default, the clock will appear to the right of your "log out" link. You can customize it by changing the value of the gsTimeInsertBefore variable. For example, to place the clock to the left of your username, set gsTimeInsertBefore to 'pt-userpage'.

Javascript

Put this in [/wiki/Special:MyPage/monobook.js your monobook.js file].

// Add time to the "personal menu" at the top of the page.
// Created by Wikipedia:User:Mathwiz2020, modified by User:JoeyDay
//
// Indicate where you would like the time to appear:
//   pt-userpage, pt-mytalk, pt-preferences,
//   pt-watchlist, pt-mycontris, pt-logout
//
gsTimeInsertBefore = ; // leave blank to append after "logout"
//
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 + ":" + minutes
  document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 5, currentTime);
  doTime = window.setTimeout("getTime()", 1000);
}
function makeTime() {
  var li = document.createElement('li');
  li.id = 'pt-time';
  var mySpan = document.createElement('span');
  mySpan.appendChild( document.createTextNode( '00:00 UTC' ) );
  li.appendChild(mySpan);
  if (gsTimeInsertBefore) {
    var before = document.getElementById(gsTimeInsertBefore);
    before.appendChild( li, before );
  }
  else {
    document.getElementById('pt-logout').parentNode.appendChild(li);
  }
  doTime = window.setTimeout("getTime()", 1000);
}
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
else if (window.attachEvent) window.attachEvent ('onload', makeTime);

CSS

Put this in [/wiki/Special:MyPage/monobook.css your monobook.css file].

#pt-time span {
   color: #666;
   font-size: 11px;
   text-transform: lowercase;
}