Dates

XCX_SPEC // AUTHORITATIVE_SOURCE

XCX 3.0 Date and Time

Creation

Dates are created using the date() function or date.now().

date: d1 = date("2024-12-25");               --- YYYY-MM-DD
date: d2 = date("25/12/2024", "DD/MM/YYYY"); --- Custom format
date: now = date.now();                      --- Current system time

Properties

Date objects expose read-only integer fields:

Arithmetic and Comparison

Dates support addition/subtraction of days and comparison against other dates.

date: tomorrow = some_date + 1;
date: yesterday = some_date - 1;
i: days_between = christmas - halloween;  --- Result in integer days
b: is_before = christmas < new_year;

Formatting

s: s1 = now.format();                    --- Default: "YYYY-MM-DD HH:mm:ss"
s: s2 = now.format("DD/MM/YYYY HH:mm");  --- Custom output

Tokens: YYYY (Year), MM (Month 01-12), DD (Day 01-31), HH (Hour 00-23), mm (Minute), ss (Second), SSS or ms (Milliseconds), M and D (No leading zero).

UP ↑