User:Gary/comments in local time.js: Difference between revisions

Content deleted Content added
Prettier, cleanup startup
fixes
 
(13 intermediate revisions by 2 users not shown)
Line 9:
* [[Wikipedia:Comments in Local Time]]
*/
$(() => {
var CommentsInLocalTime, runScript;
/**
* Given a number, add a leading zero if necessary, so that the final number
* has two characters.
*
* @param {number} number Number
* @returns {string} The number with a leading zero, if necessary.
*/
function addLeadingZero(number) {
const numberArg = number;
 
if (numberArg < 10) {
CommentsInLocalTime = (function() {
return `0${numberArg}`;
var LocalComments, language;
}
 
return numberArg;
function CommentsInLocalTime() {}
}
 
function convertMonthToNumber(month) {
language = '';
return new Date(`${month} 1, 2001`).getMonth();
}
 
function getDates(time) {
LocalComments = {};
const [, oldHour, oldMinute, oldDay, oldMonth, oldYear] = time;
 
// Today
CommentsInLocalTime.settings = function() {
const today = new Date();
if (window.LocalComments != null) {
LocalComments = window.LocalComments;
}
 
/*/ Yesterday
const yesterday = new Date();
Language
 
yesterday.setDate(yesterday.getDate() - 1);
LOCALIZING THIS SCRIPT
To localize this script, change the terms below,
to the RIGHT of the colons, to the correct term used in that language.
 
// Tomorrow
For example, in the French language,
const tomorrow = new Date();
 
tomorrow.setDate(tomorrow.getDate() + 1);
'Today' : 'Today',
 
// Set wouldthe bedate entered.
const newTime = new Date();
 
newTime.setUTCFullYear(oldYear, convertMonthToNumber(oldMonth), oldDay);
'Today' : "Aujourd'hui",
newTime.setUTCHours(oldHour);
*/
newTime.setUTCMinutes(oldMinute);
return (LocalComments.language = {
/* relative terms */
Today: 'Today',
Yesterday: 'Yesterday',
Tomorrow: 'Tomorrow',
last: 'last',
this: 'this',
 
return { time: newTime, today, tomorrow, yesterday };
/* days of the week */
}
Sunday: 'Sunday',
Monday: 'Monday',
Tuesday: 'Tuesday',
Wednesday: 'Wednesday',
Thursday: 'Thursday',
Friday: 'Friday',
Saturday: 'Saturday',
 
/**
/* months of the year */
* Determine whether to use the singular or plural word, and use that.
January: 'January',
*
February: 'February',
* @param {string} term Original term
March: 'March',
* @param {number} count Count of items
April: 'April',
* @param {string} plural Pluralized term
May: 'May',
* @returns {string} The word to use
June: 'June',
*/
July: 'July',
function pluralize(term, count, plural = null) {
August: 'August',
let pluralArg = plural;
September: 'September',
October: 'October',
November: 'November',
December: 'December',
 
// No unique pluralized word is found, so just use a general one.
/* difference words */
if (!pluralArg) {
ago: 'ago',
'frompluralArg now':= 'from now',`${term}s`;
}
 
// There's only one item, so just use the singular word.
/* date phrases */
if (count year:=== 'year',1) {
years:return 'years',term;
}
month: 'month',
months: 'months',
day: 'day',
days: 'days',
});
};
 
// There are multiple items, so use the plural word.
/*
return pluralArg;
APPLICATION
*/}
 
class CommentsInLocalTime.init = function() {
/*constructor() {
Settingsthis.language = '';
this.LocalComments = {};
*/
 
var contentText, namespace, pageAction;
/**
this.settings();
* Settings
if (LocalComments.language == null) {
return false;*/
this.settings();
 
this.language = this.setDefaultSetting(
'language',
this.LocalComments.language
);
 
// These values are also reflected in the documentation:
// https://en.wikipedia.org/wiki/Wikipedia:Comments_in_Local_Time#Default_settings
this.setDefaultSetting({
dateDifference: true,
dateFormat: 'dmy',
dayOfWeek: true,
dropDays: 0,
dropMonths: 0,
timeFirst: true,
twentyFourHours: false,
});
}
language = this.setDefaultSetting('language', LocalComments.language);
this.setDefaultSetting({
dateDifference: true,
dateFormat: 'dmy',
dayOfWeek: true,
dropDays: 0,
dropMonths: 0,
timeFirst: true,
twentyFourHours: false,
});
 
adjustTime(originalTimestamp, search) {
/*
const { time, today, tomorrow, yesterday } = getDates(
End Settings
originalTimestamp.match(search)
*/
if ( );
 
mw.config.get('wgCanonicalNamespace') == '' ||
// A string matching the date pattern was found, but it cannot be
mw.config.get('wgCanonicalNamespace') == 'MediaWiki' ||
// converted to a Date object. Return it with no changes made.
mw.config.get('wgCanonicalNamespace') == 'Special'
if (Number.isNaN(time)) {
)
return [originalTimestamp, ''];
}
 
const date = this.determineDateText({
time,
today,
tomorrow,
yesterday,
});
 
const { ampm, hour } = this.getHour(time);
const minute = addLeadingZero(time.getMinutes());
const finalTime = `${hour}:${minute}${ampm}`;
 
// Determine the time offset.
const utcValue = (-1 * time.getTimezoneOffset()) / 60;
const utcOffset =
utcValue >= 0 ? `+${utcValue}` : `−${Math.abs(utcValue.toFixed(1))}`;
 
const utcPart = `(UTC${utcOffset})`;
 
const returnDate = this.LocalComments.timeFirst
? `${finalTime}, ${date} ${utcPart}`
: `${date}, ${finalTime} ${utcPart}`;
 
return returnDate;
var disabled_urls = new Array('action=history'),
unique_url = false,
wikiPreview = new Array('action=edit', 'action=submit');
for (var i = 0; i < disabled_urls.length; i++) {
if (document.___location.href.indexOf(disabled_urls[i]) != -1) return;
}
 
convertNumberToMonth(number) {
for (var i = 0; i < wikiPreview.length; i++) {
return [
if (document.___location.href.indexOf(wikiPreview[i]) != -1)
unique_url = 'wikiPreview';this.language.January,
this.language.February,
this.language.March,
this.language.April,
this.language.May,
this.language.June,
this.language.July,
this.language.August,
this.language.September,
this.language.October,
this.language.November,
this.language.December,
][number];
}
 
createDateText({ day, month, time, today, year }) {
var element_id = unique_url ? unique_url : 'bodyContent';
// Calculate day of week
contentText = document.getElementById(element_id);
const dayNames = [
return this.replaceText(
contentText this.language.Sunday,
this.language.Monday,
/(\d{1,2}):(\d{2}), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/,
this.language.Tuesday,
);
this.language.Wednesday,
};
this.language.Thursday,
this.language.Friday,
this.language.Saturday,
];
const dayOfTheWeek = dayNames[time.getDay()];
let descriptiveDifference = '';
let last = '';
 
// Create a relative descriptive difference
CommentsInLocalTime.replaceText = function(node, search) {
if (this.LocalComments.dateDifference) {
var after,
({ descriptiveDifference, last } = this.createRelativeDate(
afterMatch,
before today,
beforeMatch, time
child, ));
children,}
 
length,
const monthName = this.convertNumberToMonth(time.getMonth());
match,
 
matches,
// Format the date according to user preferences
parent,
parentNodeName,let formattedDate = '';
 
position,
switch (this.LocalComments.dateFormat.toLowerCase()) {
span,
timeArray, case 'dmy':
formattedDate = `${day} ${monthName} ${year}`;
timestamp,
 
value,
_i, break;
_len, case 'mdy':
formattedDate = `${monthName} ${day}, ${year}`;
_results;
 
if (!node) {
return false break;
default:
formattedDate = `${year}-${month}-${addLeadingZero(day)}`;
}
 
const formattedDayOfTheWeek = this.LocalComments.dayOfWeek
? `, ${last}${dayOfTheWeek}`
: '';
 
return `${formattedDate}${formattedDayOfTheWeek}${descriptiveDifference}`;
}
 
if (node.nodeType === 3) {
/**
parent = node.parentNode;
* Create relative date data.
parentNodeName = parent.nodeName;
*
if (['CODE', 'PRE'].indexOf(parentNodeName) > -1) {
* @param {Date} returntoday false;Today
* @param {Date} time The timestamp from a comment
* @returns {Object.<string, *>} Relative date data
*/
createRelativeDate(today, time) {
/**
* The time difference from today, in milliseconds.
*
* @type {number}
*/
const millisecondsAgo = today.getTime() - time.getTime();
 
/**
* The number of days ago, that we will display. It's not necessarily the
* total days ago.
*
* @type {number}
*/
let daysAgo = Math.abs(Math.round(millisecondsAgo / 1000 / 60 / 60 / 24));
const { differenceWord, last } = this.relativeText({
daysAgo,
millisecondsAgo,
});
 
// This method of computing the years and months is not exact. However,
// it's better than the previous method that used 1 January + delta days.
// That was usually quite off because it mapped the second delta month to
// February, which has only 28 days. This method is usually not more than
// one day off, except perhaps over very distant dates.
 
/**
* The number of months ago, that we will display. It's not necessarily
* the total months ago.
*
* @type {number}
*/
let monthsAgo = Math.floor((daysAgo / 365) * 12);
 
/**
* The total amount of time ago, in months.
*
* @type {number}
*/
const totalMonthsAgo = monthsAgo;
 
/**
* The number of years ago that we will display. It's not necessarily the
* total years ago.
*
* @type {number}
*/
let yearsAgo = Math.floor(totalMonthsAgo / 12);
 
if (totalMonthsAgo < this.LocalComments.dropMonths) {
yearsAgo = 0;
} else if (this.LocalComments.dropMonths > 0) {
monthsAgo = 0;
} else {
monthsAgo -= yearsAgo * 12;
}
 
value = node.nodeValue;
if (daysAgo < this.LocalComments.dropDays) {
matches = value.match(search);
if (matches !=monthsAgo null)= {0;
matchyearsAgo = matches[0];
} else if (this.LocalComments.dropDays > 0 && totalMonthsAgo >= 1) {
position = value.search(search);
lengthdaysAgo = match.toString().length0;
} else {
beforeMatch = value.substring(0, position);
afterMatchdaysAgo -= valueMath.substringfloor(position(totalMonthsAgo * 365) +/ length12);
timeArray = this.adjustTime(match.toString(), search);
timestamp = timeArray[1] ? timeArray[1].getTime() : '';
span = document.createElement('span');
span.className = 'localcomments';
span.style.fontSize = '95%';
span.style.whiteSpace = 'nowrap';
span.setAttribute('timestamp', timestamp);
span.title = match;
span.appendChild(document.createTextNode(timeArray[0]));
parent = node.parentNode;
parent.replaceChild(span, node);
before = document.createElement('span');
before.className = 'before-localcomments';
before.appendChild(document.createTextNode(beforeMatch));
after = document.createElement('span');
after.className = 'after-localcomments';
after.appendChild(document.createTextNode(afterMatch));
parent.insertBefore(before, span);
return parent.insertBefore(after, span.nextSibling);
}
 
} else {
childrenconst descriptiveParts = [];
 
child = node.childNodes[0];
// There is years text to add.
while (child) {
if children.push(childyearsAgo > 0); {
child = childdescriptiveParts.nextSibling;push(
`${yearsAgo} ${pluralize(
this.language.year,
yearsAgo,
this.language.years
)}`
);
}
 
_results = [];
// There is months text to add.
for (_i = 0, _len = children.length; _i < _len; _i++) {
if (monthsAgo child> =0) children[_i];{
_resultsdescriptiveParts.push(this.replaceText(child, search));
`${monthsAgo} ${pluralize(
this.language.month,
monthsAgo,
this.language.months
)}`
);
}
return _results;
}
};
 
// There is days text to add.
CommentsInLocalTime.adjustTime = function(originalTimestamp, search) {
if (daysAgo > 0) {
var ampm,
descriptiveParts.push(
date,
`${daysAgo} ${pluralize(
day,
dayNames this.language.day,
dayOfTheWeek daysAgo,
this.language.days
descriptiveDifference,
finalTime, )}`
formattedDate, );
formattedDayOfTheWeek,}
 
hour,
last,return {
descriptiveDifference: ` (${descriptiveParts.join(
minute,
month ', '
monthName )} ${differenceWord})`,
oldDay last,
oldHour,};
oldMinute,
oldMonth,
oldYear,
returnDate,
time,
today,
tomorrow,
utcOffset,
year,
yesterday,
_ref,
_ref1;
time = originalTimestamp.match(search);
(_ref = [time[1], time[2], time[3], time[4], time[5]]),
(oldHour = _ref[0]),
(oldMinute = _ref[1]),
(oldDay = _ref[2]),
(oldMonth = _ref[3]),
(oldYear = _ref[4]);
today = new Date();
yesterday = new Date();
tomorrow = new Date();
yesterday.setDate(yesterday.getDate() - 1);
tomorrow.setDate(tomorrow.getDate() + 1);
time = new Date();
time.setUTCFullYear(oldYear, this.convertMonthToNumber(oldMonth), oldDay);
time.setUTCHours(oldHour);
time.setUTCMinutes(oldMinute);
if (isNaN(time)) {
return [originalTimestamp, ''];
}
 
utcOffset = (-1 * time.getTimezoneOffset()) / 60;
determineDateText({ time, today, tomorrow, yesterday }) {
utcOffset = utcOffset >= 0 ? '+' + utcOffset : '−' + Math.abs(utcOffset);
// Set the date bits to output.
year = time.getFullYear();
month const year = this.addLeadingZero(time.getMonthgetFullYear() + 1);
day const month = addLeadingZero(time.getDategetMonth() + 1);
hour const day = parseInt(time.getHoursgetDate());
 
minute = this.addLeadingZero(time.getMinutes());
// Return 'today' or 'yesterday' if that is the case
ampm = '';
if (
if (LocalComments.twentyFourHours) {
hour year === thistoday.addLeadingZerogetFullYear(hour); &&
month === addLeadingZero(today.getMonth() + 1) &&
} else {
ampm = hourday <=== 11 ? ' am' : ' pm';today.getDate()
if (hour > 12) {
hourreturn -= 12this.language.Today;
} else if (hour === 0) {
hour = 12;
}
 
if (
year === yesterday.getFullYear() &&
month === addLeadingZero(yesterday.getMonth() + 1) &&
day === yesterday.getDate()
) {
return this.language.Yesterday;
}
 
if (
year === tomorrow.getFullYear() &&
month === addLeadingZero(tomorrow.getMonth() + 1) &&
day === tomorrow.getDate()
) {
return this.language.Tomorrow;
}
 
return this.createDateText({ day, month, time, today, year });
}
 
if (
getHour(time) {
year === today.getFullYear() &&
let ampm;
month === this.addLeadingZero(today.getMonth() + 1) &&
daylet hour === todayNumber.getDateparseInt(time.getHours(), 10);
 
) {
if (this.LocalComments.twentyFourHours) {
date = language['Today'];
} else if ( ampm = '';
year == hour = yesterday.getFullYearaddLeadingZero(hour) &&;
} else {
month === this.addLeadingZero(yesterday.getMonth() + 1) &&
// Output am or pm depending on the date.
day === yesterday.getDate()
ampm = hour <= 11 ? ' am' : ' pm';
) {
 
date = language['Yesterday'];
} else if (hour > 12) {
hour -= 12;
year === tomorrow.getFullYear() &&
} else if (hour === 0) {
month === this.addLeadingZero(tomorrow.getMonth() + 1) &&
day == hour = tomorrow.getDate()12;
) { }
date = language['Tomorrow'];
} else {
dayNames = [
language['Sunday'],
language['Monday'],
language['Tuesday'],
language['Wednesday'],
language['Thursday'],
language['Friday'],
language['Saturday'],
];
dayOfTheWeek = dayNames[time.getDay()];
descriptiveDifference = '';
last = '';
if (LocalComments.dateDifference) {
(_ref1 = this.createRelativeDate(today, time)),
(descriptiveDifference = _ref1.descriptiveDifference),
(last = _ref1.last);
}
 
formattedDate = '';
return { ampm, hour };
monthName = this.convertNumberToMonth(time.getMonth());
}
formattedDate = function() {
 
switch (LocalComments.dateFormat.toLowerCase()) {
relativeText({ daysAgo, millisecondsAgo }) {
case 'dmy':
let differenceWord = '';
return day + ' ' + monthName + ' ' + year;
let last case= 'mdy':;
 
return monthName + ' ' + day + ', ' + year;
// The date is default:in the past.
if (millisecondsAgo >= 0) {
return year + '-' + month + '-' + this.addLeadingZero(day);
differenceWord = this.language.ago;
 
if (daysAgo <= 7) {
last = `${this.language.last} `;
}
 
// The date is in the future.
} else {
differenceWord = this.language['from now'];
 
if (daysAgo <= 7) {
last = `${this.language.this} `;
}
}.call(this);
formattedDayOfTheWeek = '';
if (LocalComments.dayOfWeek) {
formattedDayOfTheWeek = ', ' + last + dayOfTheWeek;
}
 
date = formattedDate + formattedDayOfTheWeek + descriptiveDifference;
return { differenceWord, last };
}
finalTime = hour + ':' + minute + ampm;
if (LocalComments.timeFirst) {
returnDate = finalTime + ', ' + date + ' (UTC' + utcOffset + ')';
} else {
returnDate = date + ', ' + finalTime + ' (UTC' + utcOffset + ')';
}
return [returnDate, time];
};
 
replaceText(node, search) {
CommentsInLocalTime.createRelativeDate = function(today, time) {
var daysAgo, if (!node) {
descriptiveParts, return;
differenceWord,
fmtDays,
fmtMonths,
fmtYears,
last,
millisecondsAgo,
monthsAgo,
totalMonthsAgo,
yearsAgo;
millisecondsAgo = today.getTime() - time.getTime();
daysAgo = Math.abs(Math.round(millisecondsAgo / 1000 / 60 / 60 / 24));
differenceWord = '';
last = '';
if (millisecondsAgo >= 0) {
differenceWord = language['ago'];
if (daysAgo <= 7) {
last = language['last'] + ' ';
}
 
} else {
// Check if this is a text node.
differenceWord = language['from now'];
if (daysAgonode.nodeType <=== 73) {
last// = language[Don't continue if this'] +text node's ';parent tag is one of these.
if (['CODE', 'PRE'].includes(node.parentNode.nodeName)) {
return;
}
 
const value = node.nodeValue;
const matches = value.match(search);
 
if (matches) {
// Only act on the first timestamp we found in this node. This is for
// the rare occassion that there is more than one timestamp in the
// same text node.
const [match] = matches;
const position = value.search(search);
const stringLength = match.toString().length;
 
// Grab the text content before and after the matching timestamp,
// which we'll then wrap in their own SPAN nodes.
const beforeMatch = value.slice(0, position);
const afterMatch = value.slice(position + stringLength);
const returnDate = this.adjustTime(match.toString(), search);
 
// Create the code to display the new local comments content.
const $span = $(
`<span class="localcomments" style="font-size: 95%;" title="${match}">${returnDate}</span>`
);
 
// Replace the existing text node in the page with our new local
// comments node.
$(node).replaceWith($span);
 
// Replace the text content that appears before the timestamp.
if (beforeMatch) {
$span.before(
`<span class="before-localcomments">${beforeMatch}</span>`
);
}
 
// Replace the text content that appears after the timestamp.
if (afterMatch) {
$span.after(
`<span class="after-localcomments">${afterMatch}</span>`
);
}
}
} else {
const children = [];
let child;
 
[child] = node.childNodes;
 
while (child) {
children.push(child);
child = child.nextSibling;
}
 
// Loop through children and run this func on it again, recursively.
children.forEach((child2) => {
this.replaceText(child2, search);
});
}
}
monthsAgo = Math.floor((daysAgo / 365) * 12);
totalMonthsAgo = monthsAgo;
yearsAgo = Math.floor(monthsAgo / 12);
if (monthsAgo < LocalComments.dropMonths) {
yearsAgo = 0;
} else if (LocalComments.dropMonths > 0) {
monthsAgo = 0;
} else {
monthsAgo = monthsAgo - yearsAgo * 12;
}
if (daysAgo < LocalComments.dropDays) {
monthsAgo = 0;
yearsAgo = 0;
} else if (LocalComments.dropDays > 0) {
daysAgo = 0;
} else {
daysAgo = daysAgo - Math.floor((totalMonthsAgo * 365) / 12);
}
descriptiveParts = [];
if (yearsAgo > 0) {
fmtYears =
yearsAgo +
' ' +
this.pluralize(language['year'], yearsAgo, language['years']);
descriptiveParts.push(fmtYears);
}
if (monthsAgo > 0) {
fmtMonths =
monthsAgo +
' ' +
this.pluralize(language['month'], monthsAgo, language['months']);
descriptiveParts.push(fmtMonths);
}
if (daysAgo > 0) {
fmtDays =
daysAgo +
' ' +
this.pluralize(language['day'], daysAgo, language['days']);
descriptiveParts.push(fmtDays);
}
return {
descriptiveDifference:
' (' + descriptiveParts.join(', ') + ' ' + differenceWord + ')',
last: last,
};
};
 
run() {
/*
HELPERS if (
['', 'MediaWiki', 'Special'].includes(
*/
mw.config.get('wgCanonicalNamespace')
)
) {
return;
}
 
// Check for disabled URLs.
CommentsInLocalTime.addLeadingZero = function(number) {
const isDisabledUrl = ['action=history'].some((disabledUrl) =>
if (number < 10) {
document.___location.href.includes(disabledUrl)
number = '0' + number;
);
 
if (isDisabledUrl) {
return;
}
 
this.replaceText(
document.querySelector('.mw-body-content .mw-parser-output'),
/(\d{1,2}):(\d{2}), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/
);
}
return number;
};
 
setDefaultSetting(...args) {
CommentsInLocalTime.convertMonthToNumber = function(month) {
// There are no arguments.
return new Date(month + ' 1, 2001').getMonth();
if (args.length === 0) {
};
return false;
}
 
// The first arg is an object, so just set that data directly onto the
CommentsInLocalTime.convertNumberToMonth = function(number) {
// settings object. like {setting 1: true, setting 2: false}
return [
languageif (typeof args[0] === 'Januaryobject'],) {
language const ['February'settings], = args;
language['March'],
language['April'],
language['May'],
language['June'],
language['July'],
language['August'],
language['September'],
language['October'],
language['November'],
language['December'],
][number];
};
 
// Loop through each setting.
CommentsInLocalTime.pluralize = function(term, count, plural) {
Object.keys(settings).forEach((name) => {
if (plural === null) {
plural = term + 's'const value = settings[name];
}
if (count === 1) {
return term;
} else {
return plural;
}
};
 
if (typeof this.LocalComments[name] === 'undefined') {
CommentsInLocalTime.setDefaultSetting = function() {
this.LocalComments[name] = value;
var defaultSetting, name, settings;
}
if (!arguments.length) {
return false });
 
}
return settings;
if (typeof arguments[0] === 'object') {
settings = arguments[0];
for (name in settings) {
defaultSetting = settings[name];
if (LocalComments[name] == null) {
LocalComments[name] = defaultSetting;
}
}
 
return settings;
// The first arg is a string, so use the first arg as the settings key,
} else if (typeof arguments[0] === 'string') {
// and the second arg as the value to set it to.
name = arguments[0];
const [name, setting] = args;
defaultSetting = arguments[1];
 
if (LocalComments[name] == null) {
if (typeof this.LocalComments[name] === 'undefined') defaultSetting;{
this.LocalComments[name] = setting;
}
 
return LocalComments[name];
return this.LocalComments[name];
}
};
 
/**
return CommentsInLocalTime;
* Set the script's settings.
})();
*
* @returns {undefined}
*/
settings() {
// The user has set custom settings, so use those.
if (window.LocalComments) {
this.LocalComments = window.LocalComments;
}
 
/**
* Language
*
* LOCALIZING THIS SCRIPT
* To localize this script, change the terms below,
* to the RIGHT of the colons, to the correct term used in that language.
*
* For example, in the French language,
*
* 'Today' : 'Today',
*
* would be
*
* 'Today' : "Aujourd'hui",
*/
this.LocalComments.language = {
// Relative terms
Today: 'Today',
Yesterday: 'Yesterday',
Tomorrow: 'Tomorrow',
last: 'last',
this: 'this',
 
// Days of the week
Sunday: 'Sunday',
Monday: 'Monday',
Tuesday: 'Tuesday',
Wednesday: 'Wednesday',
Thursday: 'Thursday',
Friday: 'Friday',
Saturday: 'Saturday',
 
// Months of the year
January: 'January',
February: 'February',
March: 'March',
April: 'April',
May: 'May',
June: 'June',
July: 'July',
August: 'August',
September: 'September',
October: 'October',
November: 'November',
December: 'December',
 
// Difference words
ago: 'ago',
'from now': 'from now',
 
// Date phrases
year: 'year',
years: 'years',
month: 'month',
months: 'months',
day: 'day',
days: 'days',
};
}
}
 
// Check if we've already ran this script.
if (window.commentsInLocalTimeWasRun) {
return;
}
 
window.commentsInLocalTimeWasRun = true;
 
const commentsInLocalTime = new CommentsInLocalTime();
 
commentsInLocalTime.run();
$(() => CommentsInLocalTime.init());
});