Skip to main content

DateTime module

📖 Description

The DateTime module contains helper functions related to handling dates and times.

Rationale

The functions in this module are primitive and probably widely available in many other open-source packages on npm. So why are they included in the Tripetto Builder package? That's because the Tripetto Builder doesn't have any dependency on other npm packages. So all the code needed to build a Tripetto form is included and these functions are simply required. Since they are part of the package, they are exported so you can use them too. For example when building custom blocks.

🗃️ Properties


🏷️ now

Returns the current time and date as number of milliseconds.

Type

number


🏷️ precise

Returns a high precision time stamp with up to microsecond precision.

Type

number


🏷️ today

Returns today 0:00 as number of milliseconds.

Type

number


🏷️ UTC

Returns the current local time as if it is that time in UTC as number of milliseconds.

Type

number


🏷️ UTCToday

Returns today 0:00 as if it is that date in UTC as number of milliseconds.

Type

number

▶️ Functions


🔧 elapsed

Returns the number of elapsed milliseconds between the current time and the supplied time.

Signature

elapsed(input: number, precise?: boolean): boolean

Parameters

NameTypeOptionalDescription
inputnumberNoSpecifies the date/time to subtract.
precisebooleanYesSpecifies if the precise or normal time should be used.

Return value

Returns the number of elapsed milliseconds between the current time and the supplied time.


🔧 isFuture

Checks if the specified date/time is in the future.

Signature

isFuture(input: number): boolean

Parameters

NameTypeOptionalDescription
inputnumberNoSpecifies the date/time to check.

Return value

Returns true if the supplied date/time is in the future.


🔧 isPast

Checks if the specified date/time is in the past.

Signature

isPast(input: number): boolean

Parameters

NameTypeOptionalDescription
inputnumberNoSpecifies the date/time to check.

Return value

Returns true if the supplied date/time is in the past.