utilsTimestamp

Comment timestamp processing utilities. Timestamp formats are set in module:siteData. Functions related to wikitext parsing go in module:wikitext.

Terminology used here (and in other modules):

  • "date" is a Date object,
  • "timestamp" is a string date as it is present on wiki pages (23:29, 10 May 2019 (UTC)).
Source:

Methods

(static) formatDate(date, addTimezoneopt) → {string}

Source:

Convert a date to a string in the format set in the settings.

Parameters:
Name Type Attributes Default Description
date Date
addTimezone boolean <optional>
false
Returns:
Type
string

(static) formatDateImproved(date, addTimezone) → {string}

Source:

Format a date in the "improved" format.

Parameters:
Name Type Description
date Date
addTimezone boolean
Returns:
Type
string

(static) formatDateNative(date, addTimezoneopt, timezoneopt) → {string}

Source:

Convert a date to a string in the default timestamp format.

Parameters:
Name Type Attributes Default Description
date Date
addTimezone boolean <optional>
false

Add the timezone postfix (for example, "(UTC+2)").

timezone string <optional>

Use the specified time zone no matter user settings.

Returns:
Type
string

(static) formatDateRelative(date) → {string}

Source:

Format a date in the "relative" format.

Parameters:
Name Type Description
date Date
Returns:
Type
string

(static) getDateFromTimestampMatch(match, timezoneopt) → {Date}

Source:
Author:
License:
  • MIT

Parse a timestamp, accepting a regexp match and returning a date.

Parameters:
Name Type Attributes Description
match Array.<string>

Regexp match data.

timezone string | number <optional>

Timezone standard name or offset in minutes. If set, it is implied that the timestamp is in the user (interface) language, not in the content language.

Returns:
Type
Date

(static) initDayjs()

Source:

For internal use. Prepare dayjs object for further use (add plugins and a locale).

(static) parseTimestamp(timestamp, timezoneopt) → (nullable) {module:utilsTimestamp~ParseTimestampReturn}

Source:

Parse a timestamp and return a date and a match object.

Parameters:
Name Type Attributes Description
timestamp string
timezone string | number <optional>

Standard timezone name or offset in minutes. If set, it is implied that the timestamp is in the user (interface) language, not in the content language.

Returns:
Type
module:utilsTimestamp~ParseTimestampReturn

Type Definitions

ParseTimestampReturn

Source:
Properties:
Name Type Description
date Date
match object
Type:
  • object