KScript docs
EN

date_format 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

FieldTypeDescription
.examplestringA date written this way, to show what it looks like: 07-03-2026 for dd-MM-yyyy (Saturday 7 March 2026, 14:05:09).
.has_dateboolTrue when it shows a day, month, year or era.
.has_timeboolTrue when it shows an hour, minute, second or AM/PM.
.tokenslistIts parts in order: ['dd', '-', 'MM', '-', 'yyyy'].

From KScript.Core

#date_format->format(date: date) → string

The date written this way: 07-03-2026.
ParameterTakes
date requireddate
Example
<let name="x" type="date_format" value="'dd MMM yyyy, HH:mm'" />
<echo>{ $x->format('2026-11-22T16:30:00'->to_date()) }</echo>
$x: date_format = 'dd MMM yyyy, HH:mm'
echo $x->format('2026-11-22T16:30:00'->to_date())

#date_format->parse(text: string) → date

Reads text written this way as a date: dd-MM-yyyy reads '07-03-2026'.
ParameterTakes
text requiredstring
Example
<let name="x" type="date_format" value="'dd MMM yyyy, HH:mm'" />
<echo>{ $x->parse('22 Nov 2026, 16:30')->format('yyyy-MM-dd') }</echo>
$x: date_format = 'dd MMM yyyy, HH:mm'
echo $x->parse('22 Nov 2026, 16:30')->format('yyyy-MM-dd')

Methods from any

Methods from string