Skip to content

DurationValue

Official

Value wrapping a duration. Durations can be used to modify a DateValue or can result from subtracting a obsidian#DateValue from another.

Import:

import { DurationValue } from 'obsidian';

Signature:

export class DurationValue extends NotNullValue

Extends: NotNullValue

Constructor

new DurationValue(years: number, months: number, days: number, hours: number, minutes: number, seconds: number, milliseconds: number)

Constructor.

To get the constructor instance, use getDurationValueConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
daysnumberThe days component of the duration.
hoursnumberThe hours component of the duration.
millisecondsnumberThe milliseconds component of the duration.
minutesnumberThe minutes component of the duration.
monthsnumberThe months component of the duration.
secondsnumberThe seconds component of the duration.
yearsnumberThe years component of the duration.

Methods

MethodReturnsDescription
addToDate(value, subtract?)DateValueModifies the provided DateValue by this duration.
fromMilliseconds(milliseconds)DurationValueCreate a new DurationValue from milliseconds.
getMilliseconds()numberConvert this duration into milliseconds.
isTruthy()booleanReturns a boolean indicating whether this obsidian#DurationValue is truthy.
parseFromString(input)DurationValue | nullCreate a new DurationValue using an ISO 8601 duration. See https://en.wikipedia.org/wiki/ISO_8601#Durations for duration format details.
toString()stringString representation of this obsidian#DurationValue.

Links to this page: