Class: Timestamp
@sapphire/timestamp.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
Name | Type | Description |
---|---|---|
pattern | string | The pattern to parse |
Defined in
Properties
pattern
• pattern: string
The raw pattern
Since
1.0.0
Defined in
template
• Private
template: TimestampTemplateEntry
[]
Since
1.0.0
Defined in
Methods
display
▸ display(time?
): string
Display the current date with the current pattern.
Since
1.0.0
Parameters
Name | Type | Description |
---|---|---|
time | TimeResolvable | The time to display |
Returns
string
Defined in
displayUTC
▸ displayUTC(time?
): string
Display the current date utc with the current pattern.
Since
1.0.0
Parameters
Name | Type | Description |
---|---|---|
time? | TimeResolvable | The time to display in utc |
Returns
string
Defined in
edit
▸ edit(pattern
): Timestamp
Edits the current pattern.
Since
1.0.0
Chainable
Parameters
Name | Type | Description |
---|---|---|
pattern | string | The new pattern for this instance |
Returns
Defined in
toString
▸ toString(): string
Defines the toString behavior of Timestamp.
Returns
string
Defined in
display
▸ Private
Static
display(template
, time
): string
Display the current date with the current pattern.
Since
1.0.0
Parameters
Name | Type | Description |
---|---|---|
template | TimestampTemplateEntry [] | The pattern to parse |
time | string | number | Date | The time to display |
Returns
string
Defined in
displayArbitrary
▸ Static
displayArbitrary(pattern
, time?
): string
Display the current date with the current pattern.
Since
1.0.0
Parameters
Name | Type | Description |
---|---|---|
pattern | string | The pattern to parse |
time | TimeResolvable | The time to display |
Returns
string
Defined in
displayUTCArbitrary
▸ Static
displayUTCArbitrary(pattern
, time?
): string
Display the current date utc with the current pattern.
Since
1.0.0
Parameters
Name | Type | Description |
---|---|---|
pattern | string | The pattern to parse |
time | TimeResolvable | The time to display |
Returns
string
Defined in
parse
▸ Private
Static
parse(pattern
): TimestampTemplateEntry
[]
Parses the pattern.
Since
1.0.0
Parameters
Name | Type | Description |
---|---|---|
pattern | string | The pattern to parse |
Returns
Defined in
resolveDate
▸ Private
Static
resolveDate(time
): Date
Resolves a date.
Since
1.0.0
Parameters
Name | Type | Description |
---|---|---|
time | TimeResolvable | The time to parse |
Returns
Defined in
utc
▸ Static
utc(time?
): Date
Creates a UTC Date object to work with.
Since
1.0.0
Parameters
Name | Type | Description |
---|---|---|
time | string | number | Date | The date to convert to utc |