duration fields and methods A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).
Fields Field Type Description .daysnumber The length in days: 1.5 for 1d12h. .hoursnumber The length in hours: 1.5 for 1h30m. .minutesnumber The length in minutes: 90 for 1h30m. .msnumber The length in milliseconds. .secondsnumber The length in seconds: 5400 for 1h30m.
From KScript.Core # duration ->add (other: duration ) → duration The two lengths added: 1h30m->add(45m) is 2h15m.
Example
.kscript XML Copy
<let name="x" type="duration" value="'1h30m'" />
<echo>{ $x->add(45m) }</echo>.kscript XML Copy
$x: duration = '1h30m'
echo $x->add(45m)# duration ->after (time?: date ) → date The time this long after a date, or after now.
Parameter Takes time optional date
Example
.kscript XML Copy
<let name="x" type="duration" value="'1h30m'" />
<echo>{ $x->after('2026-11-21T09:00:00'->to_date()) }</echo>.kscript XML Copy
$x: duration = '1h30m'
echo $x->after('2026-11-21T09:00:00'->to_date())# duration ->before (time?: date ) → date The time this long before a date, or before now.
Parameter Takes time optional date
Example
.kscript XML Copy
<let name="x" type="duration" value="'1h30m'" />
<echo>{ $x->before('2026-11-21T09:00:00'->to_date()) }</echo>.kscript XML Copy
$x: duration = '1h30m'
echo $x->before('2026-11-21T09:00:00'->to_date())# duration ->iso () → string The length in ISO 8601: PT1H30M.
Example
.kscript XML Copy
<let name="x" type="duration" value="'1h30m'" />
<echo>{ $x->iso() }</echo>.kscript XML Copy
$x: duration = '1h30m'
echo $x->iso()# duration ->subtract (other: duration ) → duration The second length taken from this one: 1h30m->subtract(45m) is 45m.
Example
.kscript XML Copy
<let name="x" type="duration" value="'1h30m'" />
<echo>{ $x->subtract(45m) }</echo>.kscript XML Copy
$x: duration = '1h30m'
echo $x->subtract(45m)Methods from any Methods from string