YouTrack Standalone 2017.3 Help

date-time

This module contains functions that let you work with dates and times.

Functions


format

static format(timestamp, format, timeZoneId)

Creates a string representation of a Unix timestamp.

Parameters

Name

Type

Description

timestamp

number

The timestamp to format as a string.

format

string

The date format to apply to the output. If no value is specified, the date format is supplied by the system. For actions that are attributed to the current user, the date format setting from the profile for the current user is applied. For actions that are attributed to the workflow user account, the global date fields format setting is applied.

timeZoneId

string

The ID of a time zone. Applies an offset to the original timestamp, which is in UTC. If no value is specified, the time zone is supplied by the system. For actions that are attributed to the current user, the local time zone setting from the profile for the current user is applied. For actions that are attributed to the workflow user account, the global default time zone is applied. For a list of time zone IDs, see JodaTime.

Return Value

Type

Description

string

A string representation of the specified timestamp.

 

parse

static parse(dateTimeString, formats, timeZoneId)

Parses a string representation of a date to return a Unix timestamp. Use this method instead of the Date.parse() method from JavaScript. For a detailed explanation, refer to the MDN documentation.

Parameters

Name

Type

Description

dateTimeString

string

The string representation of a date.

formats

string, Array.<string>

A date format that possibly matches the dateTimeString or an array of formats. If an array is provided, the formats are applied sequentially until the dateTimeString is parsed successfully. If no value is specified, the date format is supplied by the system. For actions that are attributed to the current user, the date format setting from the profile for the current user is applied. For actions that are attributed to the workflow user account, the global date fields format setting is applied.

timeZoneId

string

The ID of a time zone in which the dateTimeString occurs. This parameter is only effective when the format that matches the string does not provide any timestamp information. If neither the format that successfully matches the string nor this parameter provide the time zone, the time zone is supplied by the system. For actions that are attributed to the current user, the local time zone setting from the profile for the current user is applied. For actions that are attributed to the workflow user account, the global default time zone is applied. For a list of time zone IDs, see JodaTime.

Return Value

Type

Description

number

A timestamp representation of the specified string.

 

toPeriod

static toPeriod(period)

Creates a period representation of an argument.

Parameters

Name

Type

Description

period

number, string

A duration in milliseconds as either a number or a string.

Return Value

Type

Description

Period

The period representation of the specified argument.

Example

issue.fields.Estimation = dateTime.toPeriod(3 * 3600 * 1000); // 3h in ms issue.fields.Estimation = dateTime.toPeriod('3h'); // short form issue.fields.Estimation = dateTime.toPeriod('2w4d3h15m'); // full form

See Also

 

Last modified: 7 March 2019