Oslo

TimeSpan

Represents a time-span. Supports negative values.

Constructor

function constructor(value: number, unit: TimeSpanUnit): this;

Parameters

  • value
  • unit: ms for milliseconds, s for seconds, etc

Methods

Properties

interface Properties {
	unit: TimeSpanUnit;
	value: number;
}
  • unit
  • value

Example

import { TimeSpan } from "oslo";

const halfSeconds = new TimeSpan(500, "ms");
const tenSeconds = new TimeSpan(10, "s");
const halfHour = new TimeSpan(30, "m");
const oneHour = new TimeSpan(1, "h");
const oneDay = new TimeSpan(1, "d");
const oneWeek = new TimeSpan(1, "w");