Skip to main content

Class: Timestamp

@sapphire/time-utilities.Timestamp

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

Constructors

constructor

โ€ข new Timestamp(pattern)

Starts a new Timestamp and parses the pattern.

since 1.0.0

Parameters

NameTypeDescription
patternstringThe pattern to parse

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:142

Properties

pattern

โ€ข pattern: string

The raw pattern

since 1.0.0

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:130


template

โ€ข Private template: TimestampTemplateEntry[]

since 1.0.0

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:135

Methods

display

โ–ธ display(time?): string

Display the current date with the current pattern.

since 1.0.0

Parameters

NameTypeDescription
timeTimeResolvableThe time to display

Returns

string

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:152


displayUTC

โ–ธ displayUTC(time?): string

Display the current date utc with the current pattern.

since 1.0.0

Parameters

NameTypeDescription
time?TimeResolvableThe time to display in utc

Returns

string

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:161


edit

โ–ธ edit(pattern): Timestamp

Edits the current pattern.

since 1.0.0

chainable

Parameters

NameTypeDescription
patternstringThe new pattern for this instance

Returns

Timestamp

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:171


toString

โ–ธ toString(): string

Defines the toString behavior of Timestamp.

Returns

string

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:180


display

โ–ธ Static Private display(template, time): string

Display the current date with the current pattern.

since 1.0.0

Parameters

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

Returns

string

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:220


displayArbitrary

โ–ธ Static displayArbitrary(pattern, time?): string

Display the current date with the current pattern.

since 1.0.0

Parameters

NameTypeDescription
patternstringThe pattern to parse
timeTimeResolvableThe time to display

Returns

string

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:190


displayUTCArbitrary

โ–ธ Static displayUTCArbitrary(pattern, time?): string

Display the current date utc with the current pattern.

since 1.0.0

Parameters

NameTypeDescription
patternstringThe pattern to parse
timeTimeResolvableThe time to display

Returns

string

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:200


parse

โ–ธ Static Private parse(pattern): TimestampTemplateEntry[]

Parses the pattern.

since 1.0.0

Parameters

NameTypeDescription
patternstringThe pattern to parse

Returns

TimestampTemplateEntry[]

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:232


resolveDate

โ–ธ Static Private resolveDate(time): Date

Resolves a date.

since 1.0.0

Parameters

NameTypeDescription
timeTimeResolvableThe time to parse

Returns

Date

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:261


utc

โ–ธ Static utc(time?): Date

Creates a UTC Date object to work with.

since 1.0.0

Parameters

NameTypeDescription
timestring | number | DateThe date to convert to utc

Returns

Date

Defined in

projects/utilities/packages/time-utilities/src/lib/Timestamp.ts:209