-
Notifications
You must be signed in to change notification settings - Fork 0
Guide Dates
ARO provides comprehensive date and time handling capabilities. This guide covers all date/time operations available in ARO.
The <now> variable is always available without declaration. It returns the current date/time in UTC:
(* Log current time *)
<Log> <now> to the <console>.
Output: 2025-12-29T15:20:49Z
Access <now> in different timezones using qualifiers:
(* UTC (default) *)
<Log> <now: utc> to the <console>.
(* Local system time *)
<Log> <now: local> to the <console>.
(* IANA timezone names *)
<Log> <now: Europe/Berlin> to the <console>.
<Log> <now: America/New_York> to the <console>.
<Log> <now: Asia/Tokyo> to the <console>.
Extract individual components from dates using qualifiers:
(* Get year from current date *)
<Extract> the <year> from the <now: year>.
(* Get month (1-12) *)
<Extract> the <month> from the <now: month>.
(* Get day of month (1-31) *)
<Extract> the <day> from the <now: day>.
(* Get hour (0-23) *)
<Extract> the <hour> from the <now: hour>.
(* Get minute (0-59) *)
<Extract> the <minute> from the <now: minute>.
(* Get second (0-59) *)
<Extract> the <second> from the <now: second>.
(* Get day of week (Sunday=1, Monday=2, ..., Saturday=7) *)
<Extract> the <day-of-week> from the <now: dayOfWeek>.
(* Get Unix timestamp *)
<Extract> the <timestamp> from the <now: timestamp>.
(* Get ISO 8601 string *)
<Extract> the <iso-string> from the <now: iso>.
Parse ISO 8601 date strings into ARODate objects:
(* Parse a date string *)
<Compute> the <meeting: date> from "2025-06-15T14:00:00Z".
(* Extract properties from parsed date *)
<Extract> the <meeting-year> from the <meeting: year>.
<Extract> the <meeting-month> from the <meeting: month>.
Supported formats:
- Full ISO 8601:
2025-06-15T14:00:00Z - With timezone offset:
2025-06-15T14:00:00+02:00 - Date only:
2025-06-15 - Date with time:
2025-06-15T14:00:00
Format dates using pattern strings:
(* Format current date *)
<Compute> the <formatted: format> from <now> with "MMMM dd, yyyy".
(* Result: "December 29, 2025" *)
<Compute> the <short-date: format> from <now> with "MMM dd, yyyy".
(* Result: "Dec 29, 2025" *)
<Compute> the <time-only: format> from <now> with "HH:mm:ss".
(* Result: "15:20:49" *)
<Compute> the <european: format> from <now> with "dd.MM.yyyy".
(* Result: "29.12.2025" *)
| Pattern | Description | Example |
|---|---|---|
yyyy |
4-digit year | 2025 |
yy |
2-digit year | 25 |
MMMM |
Full month name | December |
MMM |
Abbreviated month | Dec |
MM |
2-digit month | 12 |
dd |
2-digit day | 29 |
d |
Day without leading zero | 29 |
EEEE |
Full weekday name | Sunday |
EEE |
Abbreviated weekday | Sun |
HH |
Hour (24-hour, 00-23) | 15 |
hh |
Hour (12-hour, 01-12) | 03 |
mm |
Minute (00-59) | 20 |
ss |
Second (00-59) | 49 |
a |
AM/PM marker | PM |
Z |
Timezone offset | +0000 |
Create dates relative to another date using offset qualifiers:
(* Add time *)
<Compute> the <tomorrow: +1d> from <now>.
<Compute> the <next-week: +7d> from <now>.
<Compute> the <in-one-hour: +1h> from <now>.
<Compute> the <in-30-minutes: +30m> from <now>.
(* Subtract time *)
<Compute> the <yesterday: -1d> from <now>.
<Compute> the <last-week: -7d> from <now>.
<Compute> the <one-hour-ago: -1h> from <now>.
| Unit | Description | Example |
|---|---|---|
s |
Seconds |
+30s, -10s
|
m |
Minutes |
+15m, -5m
|
h |
Hours |
+2h, -1h
|
d |
Days |
+1d, -7d
|
w |
Weeks |
+2w, -1w
|
M |
Months |
+1M, -3M
|
y |
Years |
+1y, -2y
|
Create and work with date ranges:
(* Create a date range *)
<Create> the <vacation: date-range> from <start-date> to <end-date>.
(* Get range properties *)
<Extract> the <days> from the <vacation: days>.
<Extract> the <hours> from the <vacation: hours>.
<Extract> the <minutes> from the <vacation: minutes>.
<Extract> the <seconds> from the <vacation: seconds>.
(* Get range endpoints *)
<Extract> the <start> from the <vacation: start>.
<Extract> the <end> from the <vacation: end>.
Check if a date falls within a range using in operator in when clauses:
when <booking-date> in <vacation> {
<Log> "Booking is during vacation" to the <console>.
}
when <check-date> not in <vacation> {
<Log> "Date is outside vacation period" to the <console>.
}
Calculate the distance between two dates:
(* Calculate distance to deadline *)
<Compute> the <remaining: distance> from <now> to <deadline>.
(* Get distance in various units *)
<Extract> the <days-left> from the <remaining: days>.
<Extract> the <hours-left> from the <remaining: hours>.
<Extract> the <minutes-left> from the <remaining: minutes>.
<Extract> the <seconds-left> from the <remaining: seconds>.
Create recurring schedules:
(* Simple intervals *)
<Create> the <daily: recurrence> with "every day".
<Create> the <weekly: recurrence> with "every week".
<Create> the <biweekly: recurrence> with "every 2 weeks".
<Create> the <monthly: recurrence> with "every month".
(* Weekday-based *)
<Create> the <mondays: recurrence> with "every monday".
<Create> the <fridays: recurrence> with "every friday".
<Create> the <second-tuesday: recurrence> with "every second tuesday".
<Create> the <last-friday: recurrence> with "every last friday".
(* Get next occurrence *)
<Extract> the <next-meeting> from the <weekly: next>.
(* Get previous occurrence *)
<Extract> the <last-meeting> from the <weekly: previous>.
(* Get pattern string *)
<Extract> the <pattern> from the <weekly: pattern>.
Compare dates in when clauses:
(* Before/after comparisons *)
when <booking-date> before <deadline> {
<Log> "Booking is before deadline" to the <console>.
}
when <event-date> after <now> {
<Log> "Event is in the future" to the <console>.
}
(* Combined with other conditions *)
when <order-date> after <start> and <order-date> before <end> {
<Log> "Order is within the period" to the <console>.
}
(Application-Start: Booking System) {
<Log> "=== Booking System ===" to the <console>.
(* Get current time *)
<Log> <now> to the <console>.
(* Parse booking deadline *)
<Compute> the <deadline: date> from "2025-12-31T23:59:59Z".
(* Calculate days remaining *)
<Compute> the <remaining: distance> from <now> to <deadline>.
<Extract> the <days-left> from the <remaining: days>.
<Log> <days-left> to the <console>.
(* Check if booking is still open *)
when <now> before <deadline> {
<Log> "Bookings are still open!" to the <console>.
}
(* Format deadline for display *)
<Compute> the <formatted-deadline: format> from <deadline> with "MMMM dd, yyyy".
<Log> <formatted-deadline> to the <console>.
(* Create weekly reminder schedule *)
<Create> the <reminders: recurrence> with "every monday".
<Extract> the <next-reminder> from the <reminders: next>.
<Log> <next-reminder> to the <console>.
<Return> an <OK: status> for the <booking-system>.
}
-
Always use UTC for storage - Store dates in UTC and convert to local time only for display.
-
Use ISO 8601 for exchange - When sending dates between systems, use ISO 8601 format.
-
Validate date ranges - Ensure start dates come before end dates when creating ranges.
-
Handle timezone carefully - Be explicit about timezones when working with dates across regions.
-
Use recurrence for scheduling - Prefer recurrence patterns over manual date calculations for repeating events.
- Advanced Features Specification - Date/time handling specification
- Guide: Computations
- Guide: Control Flow
Fundamentals
- The Basics
- Feature Sets
- Actions
- Variables
- Type System
- Control Flow
- Error Handling
- Computations
- Dates
- Concurrency
Runtime & Events
I/O & Communication
Advanced