Wikibooks:Comments in Local Time

Comments in Local Time is a gadget that converts timestamps, including those that appear in signatures, from Coordinated Universal Time to your local time. The code was imported from User:Gary King/comments in local time.js to MediaWiki:Gadget-CommentsInLocalTime.js.

Installation

edit
 
Before Comments in Local Time is used
 
After Comments in Local Time is used

To enable this gadget, go to your preferences, click on the "Gadgets" tab, and checkmark the box labeled "Change UTC-based time and date stamps, such as those used in talk page comments, to be relative to local time."

Examples

edit

This:

00:00 1 January 2009 (UTC)

Appears as

31 December 2008, Wednesday (2 days ago), 7:00 pm (UTC-5)

The date returned is shown in your local time, based on your computer's timezone settings. Dates that are either today, yesterday, or tomorrow are shown with a relative dates, such as

Today, 0:00 am (UTC-5)

Settings

edit

Default settings

edit
LocalComments = {
	dateDifference: true,
	dateFormat: 'dmy',
	timeFirst: true,
	twentyFourHours: false
};

Custom settings

edit

To change the default settings, copy the above code to your vector.js (or common.js) page and change the values after the equals sign. The settings are explained in greater detail below.

dateDifference
Shows the difference in terms of days, months, and years from the timestamp and today's date.
Options: true to show the difference between the timestamp and today's date, and false to hide the difference
dateFormat
Changes the date's format.
Options: 'dmy' for "1 January 2009", 'mdy' for "January 1, 2009", and 'ymd' for "2009-01-01"
timeFirst
Changes the order in which the time and date appears in timestamps.
Options: true for the time to appear before the date, and false for the date to appear before the time
twentyFourHours
Uses a 24-hour clock instead of the default 12-hour clock.
Options: false for a 12-hour clock, and true for a 24-hour clock

Style

edit

To change the timestamp's style, add the code below to your vector.css page and modify it using Cascading Style Sheets. For example, to change the timestamp's size, increase or decrease the percentage in the code accordingly, such as to 90%.

.localcomments { font-size: 100% !important; }