Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Wikipedia:Comments in Local Time

From Wikipedia, the free encyclopedia
Shortcuts

Comments in Local Time (source code) is agadget that changesUTC-based dates, such as those in signatures, to be relative to the user's local time. It also adds the day of the week to dates, and uses common phrases to describe dates (i.e., Today, 2 months ago, etc.).

This script uses plain JavaScript, making pages load significantly faster than if the script used jQuery.

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

Installation

[edit]

To enable this gadget, navigate to:

Alternatively, this script can also be installed by copying the code below to your custom JavaScript file atSpecial:MyPage/common.js:

importScript('User:Gary/comments in local time.js');// [[User:Gary/comments in local time.js]]

Examples

[edit]

00:00 1 January 2011 (UTC) is changed to7:00 pm, 31 December 2010, Friday (1 month, 2 days ago) (UTC-5).

The date is shown in your local time, based on your computer's timezone setting. The display is highly customizable through the use of options. For instance:

00:00 1 January 2011 (UTC) can instead be changed to19:00, December 31, 2010, (33 days ago) (UTC-5).

Dates that are either today, yesterday, or tomorrow are shown with relative dates, such asToday, 1:00 am (UTC-5).

Settings

[edit]

Default settings

[edit]
window.LocalComments={dateDifference:true,dateFormat:'dmy',dayOfWeek:true,dropDays:0,dropMonths:0,timeFirst:true,twentyFourHours:false,};

Custom settings

[edit]

To change the default settings, copy the above code to yourcustom JavaScript file, placing it before theimportScript used to import this script, and change the values after the colon. The settings are explained in greater detail below. After changing the settings, force your browser to perform a full reload of a talk page to see the effect.

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, andfalse 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"
dayOfWeek
Displays the day of the week.
Options:true to add the day of the week, andfalse to suppress the day of the week
dropDays
Number of days in difference at which point only the number of months is displayed.
Options:0 to always show the number of days, and >0 to set a maximum number of days to show
dropMonths
Number of months in difference at which point only the number of years is displayed.
Options:0 to always show the number of months, and >0 to set a maximum number of months to show
timeFirst
Changes the order in which the time and date appears in timestamps.
Options:true for the time to appear before the date, andfalse for the date to appear before the time
twentyFourHours
Uses a24-hour clock instead of the default12-hour clock.
Options:false for a12-hour clock, andtrue for a24-hour clock
Usage of dropDays and dropMonths
dropDaysdropMonthsDays differenceDisplayed text
00752 months, 14 days
001705 months, 18 days
004001 year, 1 month, 3 days
008002 years, 2 months, 7 days
9307575 days
9301705 months
9304001 year, 1 month
9308002 years, 2 months
024752 months, 14 days
0241705 months, 18 days
02440013 months, 3 days
0248002 years
93247575 days
93241705 months
932440013 months
93248002 years

Settings for minimum display text

[edit]

To produce the smallest display text that still includes the date difference, copy the following code to yourcustom JavaScript file:

window.LocalComments={dateDifference:true,dateFormat:'dmy',dayOfWeek:false,dropDays:93,dropMonths:24,timeFirst:true,twentyFourHours:true,};

To produce the absolute smallest display text, suppress the date difference entirely by copying the following code to yourcustom JavaScript file:

window.LocalComments={dateDifference:false,dateFormat:'dmy',dayOfWeek:false,dropDays:93,dropMonths:24,timeFirst:true,twentyFourHours:true,};

Style

[edit]

To change the timestamp's style, add the code below toyour common.css page and modify it usingCascading Style Sheets. For example, to change the timestamp's size, increase or decrease the percentage in the code accordingly, such as to100% (it's set at 95% font size by default).

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

Local time

[edit]

The script draws local time for signatures from the time set on the user's computer. The time for logs and page histories is drawn from the time set in the appearance tab in each user'spreferences.

Localization

[edit]

To use this script on another Wikipedia language, copy the code fromcomments in local time.js, and follow the instructions underLOCALIZING THIS SCRIPT in the script's comments. The regular expression used to find timestamps may also need to be updated, on the line followingdocument.querySelector('.mw-parser-output').

See also

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=Wikipedia:Comments_in_Local_Time&oldid=1310090416"
Category:

[8]ページ先頭

©2009-2026 Movatter.jp