Skip to content

@mcsb/api / Exports / UnixDate

Class: UnixDate ​

An extension of Date which overrides the toJSON function to return the unix timestamp value (Date.getTime()) instead of an ISO 8601 string. This can be used to avoid pre-/post-processing on stringified objects. Specifically, this is used by Starboard to easily convert Hypixel API unix timestamps back into timestamps after stringifying, so the output mirrors that of the Hypixel API.

Hierarchy ​

  • Date

    ↳ UnixDate

Table of contents ​

Constructors ​

Methods ​

Constructors ​

constructor ​

• new UnixDate()

Inherited from ​

Date.constructor

Defined in ​

node_modules/typescript/lib/lib.es5.d.ts:917

• new UnixDate(value)

Parameters ​

NameType
valuestring | number

Inherited from ​

Date.constructor

Defined in ​

node_modules/typescript/lib/lib.es5.d.ts:918

• new UnixDate(year, monthIndex, date?, hours?, minutes?, seconds?, ms?)

Creates a new Date.

Parameters ​

NameTypeDescription
yearnumberThe full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
monthIndexnumberThe month as a number between 0 and 11 (January to December).
date?numberThe date as a number between 1 and 31.
hours?numberMust be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
minutes?numberMust be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
seconds?numberMust be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
ms?numberA number from 0 to 999 that specifies the milliseconds.

Inherited from ​

Date.constructor

Defined in ​

node_modules/typescript/lib/lib.es5.d.ts:929

• new UnixDate(value)

Parameters ​

NameType
valuestring | number | Date

Inherited from ​

Date.constructor

Defined in ​

node_modules/typescript/lib/lib.es2015.core.d.ts:88

Methods ​

toJSON ​

▸ toJSON(): any

Returns ​

any

Overrides ​

Date.toJSON

Defined in ​

packages/api/src/util.ts:37

Released under the MIT License.