Utility module for transforming between Unix timestamp integers and formatted date strings. Supports various date/time formats and localization options.

Methods

(inner) date(timestamp) → {string}

Formats Unix timestamp to ISO date string (YYYY-MM-DD)

Parameters:
NameTypeDescription
timestampinteger

Unix timestamp in seconds

Returns:

ISO date string

Type: 
string

(inner) dateString(params) → {string}

Formats a Unix timestamp into a localized date string. If not explicit in the param the language for the locale will be taken from the mapp.user object or fallback to the default format.

Parameters:
NameTypeDescription
paramsObject

Input parameters

Properties
NameTypeAttributesDefaultDescription
params.valuenumber

Unix timestamp in seconds

params.newValuenumber<optional>

Updated timestamp value (takes precedence over value)

params.localestring<optional>
en-GB

Locale identifier

params.optionsIntl.DateTimeFormatOptions<optional>

Formatting options

Returns:

Formatted date string

Type: 
string

(inner) dateToUnixEpoch(dateStropt) → {number}

Converts a date string to Unix timestamp. The current data will be used if no dateStr is provided.

Parameters:
NameTypeAttributesDescription
dateStrstring<optional>

Date string parseable by JavaScript Date

Throws:

If date string is invalid

Type
Error
Returns:

Unix timestamp in seconds

Type: 
number

(inner) datetime(timestamp) → {string}

Formats Unix timestamp to ISO datetime string (YYYY-MM-DDThh:mm:ss)

Parameters:
NameTypeDescription
timestampinteger

Unix timestamp in seconds

Returns:

ISO datetime string without timezone

Type: 
string