Skip to content

computeTime

The computeTime() function converts a TheTime or SerializedTheTime into a numeric value in the requested unit.

Interactive example

Syntax

Classic signature

typescript
function computeTime(
	input: TheTime | SerializedTheTime,
	unit: "week" | "day" | "hour" | "minute" | "second" | "millisecond"
): number

Curried signature

typescript
function computeTime(
	unit: "week" | "day" | "hour" | "minute" | "second" | "millisecond"
): (input: TheTime | SerializedTheTime) => number

Parameters

  • input: Duration value (TheTime or SerializedTheTime).
  • unit: Target unit.

Return value

A numeric value converted to the requested unit.

See also

Released under the MIT license.