Skip to main content

Class: Timestamp

Timestamp class, parses the pattern once, displays the desired Date or UNIX timestamp with the selected pattern.

Constructors​

new Timestamp()​

new Timestamp(pattern: string): Timestamp

Starts a new Timestamp and parses the pattern.

Parameters​

ParameterTypeDescription
patternstringThe pattern to parse

Returns​

Timestamp

Since​

1.0.0

Defined in​

Timestamp.ts:142

Properties​

pattern​

pattern: string

The raw pattern

Since​

1.0.0

Defined in​

Timestamp.ts:130


template​

private template: TimestampTemplateEntry[]

Since​

1.0.0

Defined in​

Timestamp.ts:135

Methods​

display()​

display(time: TimeResolvable): string

Display the current date with the current pattern.

Parameters​

ParameterTypeDescription
timeTimeResolvableThe time to display

Returns​

string

Since​

1.0.0

Defined in​

Timestamp.ts:152


displayUTC()​

displayUTC(time?: TimeResolvable): string

Display the current date utc with the current pattern.

Parameters​

ParameterTypeDescription
time?TimeResolvableThe time to display in utc

Returns​

string

Since​

1.0.0

Defined in​

Timestamp.ts:161


edit()​

edit(pattern: string): this

Edits the current pattern.

Parameters​

ParameterTypeDescription
patternstringThe new pattern for this instance

Returns​

this

Since​

1.0.0

Chainable​

Defined in​

Timestamp.ts:171


toString()​

toString(): string

Defines the toString behavior of Timestamp.

Returns​

string

Defined in​

Timestamp.ts:180


display()​

private static display(template: TimestampTemplateEntry[], time: string | number | Date): string

Display the current date with the current pattern.

Parameters​

ParameterTypeDescription
templateTimestampTemplateEntry[]The pattern to parse
timestring | number | DateThe time to display

Returns​

string

Since​

1.0.0

Defined in​

Timestamp.ts:220


displayArbitrary()​

static displayArbitrary(pattern: string, time: TimeResolvable): string

Display the current date with the current pattern.

Parameters​

ParameterTypeDescription
patternstringThe pattern to parse
timeTimeResolvableThe time to display

Returns​

string

Since​

1.0.0

Defined in​

Timestamp.ts:190


displayUTCArbitrary()​

static displayUTCArbitrary(pattern: string, time: TimeResolvable): string

Display the current date utc with the current pattern.

Parameters​

ParameterTypeDescription
patternstringThe pattern to parse
timeTimeResolvableThe time to display

Returns​

string

Since​

1.0.0

Defined in​

Timestamp.ts:200


parse()​

private static parse(pattern: string): TimestampTemplateEntry[]

Parses the pattern.

Parameters​

ParameterTypeDescription
patternstringThe pattern to parse

Returns​

TimestampTemplateEntry[]

Since​

1.0.0

Defined in​

Timestamp.ts:232


resolveDate()​

private static resolveDate(time: TimeResolvable): Date

Resolves a date.

Parameters​

ParameterTypeDescription
timeTimeResolvableThe time to parse

Returns​

Date

Since​

1.0.0

Defined in​

Timestamp.ts:261


utc()​

static utc(time: string | number | Date): Date

Creates a UTC Date object to work with.

Parameters​

ParameterTypeDescription
timestring | number | DateThe date to convert to utc

Returns​

Date

Since​

1.0.0

Defined in​

Timestamp.ts:209