← Back to Documentation

Working with Dates

Date and time handling with timezone support, relative offsets, ranges, and recurrence patterns.

The Magic <now> Variable

ARO provides a special <now> variable that's always available without declaration. It returns the current date and time in UTC:

(* Log the current time *)
<Log> <now> to the <console>.

Output: 2025-12-29T15:20:49Z

UTC by Default

All dates in ARO are UTC unless explicitly converted. This eliminates timezone bugs and ensures consistent behavior across systems.

Extracting Date Components

Extract individual parts of a date using qualifiers:

<Extract> the <year> from the <now: year>.
<Extract> the <month> from the <now: month>.
<Extract> the <day> from the <now: day>.
<Extract> the <hour> from the <now: hour>.

Available Properties

PropertyDescriptionExample
yearFour-digit year2025
monthMonth (1-12)12
dayDay of month (1-31)29
hourHour (0-23)15
minuteMinute (0-59)20
secondSecond (0-59)49
dayOfWeekDay of week (1=Sun, 7=Sat)1
timestampUnix timestamp1735485649
isoISO 8601 string2025-12-29T15:20:49Z

Parsing Date Strings

Convert ISO 8601 strings into date objects:

<Compute> the <deadline: date> from "2025-12-31T23:59:59Z".
<Extract> the <deadline-year> from the <deadline: year>.

Formatting Dates

Format dates for display using pattern strings:

<Compute> the <display: format> from <now> with "MMMM dd, yyyy".
(* Result: "December 29, 2025" *)

<Compute> the <short: format> from <now> with "MMM dd".
(* Result: "Dec 29" *)

Format Patterns

PatternResult
yyyy-MM-dd2025-12-29
MMMM dd, yyyyDecember 29, 2025
dd.MM.yyyy29.12.2025
HH:mm:ss15:20:49

Relative Offsets

Calculate dates relative to other dates:

<Compute> the <tomorrow: +1d> from <now>.
<Compute> the <yesterday: -1d> from <now>.
<Compute> the <next-week: +7d> from <now>.
<Compute> the <expires: +24h> from <created>.

Offset Units

UnitDescription
sSeconds
mMinutes
hHours
dDays
wWeeks
MMonths
yYears

Date Ranges

Create and work with date ranges:

<Create> the <vacation: date-range> from <start> to <end>.
<Extract> the <duration> from the <vacation: days>.

Date Comparisons

Compare dates in when clauses:

when <booking> before <deadline> {
    <Log> "Booking accepted" to the <console>.
}

when <event> after <now> {
    <Log> "Upcoming event" to the <console>.
}

Recurrence Patterns

Define recurring schedules:

<Create> the <weekly: recurrence> with "every monday".
<Extract> the <next> from the <weekly: next>.

Pattern Examples

Learn More

See the ARO-0041 proposal for the complete date/time specification.

{{scripts}}