r99543 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99542‎ | r99543 | r99544 >
Date:19:39, 11 October 2011
Author:jpostlethwaite
Status:deferred
Tags:
Comment:
Adding in javascript code in case we need to handle timezones.
Modified paths:
  • /trunk/extensions/LastModified/modules/lastmodified.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LastModified/modules/lastmodified.js
@@ -32,12 +32,8 @@
3333 var displayRange = extensionsLastModifiedGetMetaRange();
3434 //console.log( 'displayRange: ' + displayRange );
3535
36 - // Get the current Date object
37 - var now = new Date();
38 - //console.log( 'now: ' + now );
39 -
4036 // Get the current timestamp and remove the milliseconds
41 - var nowStamp = parseInt( now.getTime() / 1000 ) ;
 37+ var nowStamp = extensionsLastModifiedGetUtcTimeStamp();
4238 //console.log( 'nowStamp: ' + nowStamp );
4339
4440 // Get the difference in the time from when it was last edited.
@@ -51,7 +47,35 @@
5248 // Insert the text on the web page
5349 extensionsLastModifiedInsertHtml( lastModifiedText );
5450 }
 51+/**
 52+ * Get the UTC Timestamp without microseconds
 53+ *
 54+ * @todo
 55+ * - What do we need to do about timezones?
 56+ *
 57+ * @return integer
 58+ */
 59+function extensionsLastModifiedGetUtcTimeStamp() {
 60+
 61+ // Get the current Date object
 62+ var now = new Date();
 63+ //console.log( 'now: ' + now );
 64+
 65+ return parseInt( now.getTime() / 1000 );
5566
 67+ // Return the UTC timestamp
 68+ return parseInt(
 69+ Date.UTC(
 70+ now.getUTCFullYear(),
 71+ now.getUTCMonth(),
 72+ now.getUTCDay(),
 73+ now.getUTCHours(),
 74+ now.getUTCMinutes(),
 75+ now.getUTCSeconds()
 76+ ) / 1000
 77+ );
 78+}
 79+
5680 /**
5781 * Get the article history link
5882 *

Status & tagging log